I noticed this morning that my JSF application running on GlassFish 4.1 was throwing the following error when my users log out of the web application:
- WELD-000019: Error destroying an instance null of Managed Bean [...MyAuthenticator] with qualifiers [@Default @Named @Any]
MyAuthenticator is a javax.faces.view.ViewScoped CDI bean with an @PreDestroy annotated method.
As a test, I removed the @PreDestroy annotation and verified that the error disappeared.
I then added the @PreDestroy annotation back to MyAuthenticator along with many debug messages and performed the following tests:
Test 1
- Logged into the application.
- Logged out of application.
Test 2
- Logged into the application.
- Allowed session to expire.
The debug messages showed the following behaviour in both tests:
- MyAuthenticator is created and the login form is displayed.
- MyAuthenticator is destroyed immediately after the user login form is submitted and the user is logged in.
- When session is invalidated or expires, Weld throws the reported error.
I believe that error is the result of Weld calling the @PreDestroy method on my already destroyed MyAuthenticator.
Questions
- Is this a bug in Weld?
- Can I safely ignore?