Why does Weld in GlassFish 4.1 call the @PreDestroy method on the already destroyed ViewScoped beans after calling invalidateSession?

This morning, I noticed that a JSF application running on GlassFish 4.1 throws the following error when my users exit a web application:

  • WELD-000019: Error destroying null instance from managed Bean [... MyAuthenticator] with qualifiers [@Default @Named @Any]

MyAuthenticator is a javax.faces.view.ViewScoped CDI Bean with the annotated @PreDestroy method.

As a test, I removed the @PreDestroy annotation and confirmed that the error went away.

Then I added the @PreDestroy annotation back to MyAuthenticator along with many debug messages, and performed the following tests:

Test 1

  • Recorded in the application.
  • Out of application.

Test 2

  • Recorded in the application.
  • Validity of the allowed session.

Debug messages showed the following behavior in both tests:

  • Created by MyAuthenticator and the login form is displayed.
  • MyAuthenticator is destroyed immediately after sending the user login form and user login.
  • When the session is invalid or expires, Weld will display an error message.

I believe the error is the result of Weld calling the @PreDestroy method for my already destroyed MyAuthenticator.

Questions

  • Is this a bug in Weld?
  • Is it safe to ignore?
+5
source share
1 answer

This issue is resolved in GlassFish 4.1.2.

0
source

Source: https://habr.com/ru/post/1214431/


All Articles