| Martin Kouba thanks for prompt reply. Firstly, I just looked carefully again with fresh Glassfish5 (WELD 3.0.0 (Final)). It may indeed be preventing remove() on non-@Dependent, but either it's not throwing UnsupportedOperationException (http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#session_bean_ejb_remove_method) or it's percolating up as:
ERROR: WELD-000019: Error destroying an instance
|
I have a complete test NetBeans 8.2 app: https://github.com/webelcomau/EJBvsCDIvsJSF Very easy to run. It has full instructions, and very detailed discussion, but you will get the gist from the first couple of paragraphs of the description and by just running it. Basically it tries out lots of differently scoped session beans of different types (and under different injection @Inject and @EJB) and logs the lifecycle callbacks. Just download it, open it in NetBeans-8.2 (Glassfish-4.1.1 has an older Weld, but installing latest into GF4.1.1 tricky), then run. On the index page when it runs there is a switch you should activate (or try it out first without the switch to see what it does):
On @PreDestroy of backing beans, force remove() @Stateful beans injected with @Inject ? [x]
|
It is normally off. Then click on one of the test pages for various backing bean scopes (@RequestScoped test will do). Example output without "force remove()" switch OFF (rely on CDI contextual lifecycle management):
Info: StatefulEjb [1516100247067]: postConstruct |
Info: StatefulInject [1516100247069]: postConstruct |
Info: StatefulDepend [1516100247070]: postConstruct |
Info: Jsf23RequestBean [1516100247066]: postConstruct |
Info: StatefulEjb [1516100247067]: exec |
Info: StatefulInject [1516100247069]: exec |
Info: StatefulDepend [1516100247070]: exec |
Info: StatefulRequest [1516100247072]: postConstruct |
Info: StatefulRequest [1516100247072]: exec |
Info: StatefulViewView [1516100247073]: postConstruct |
Info: StatefulViewView [1516100247073]: exec |
Info: StatefulOmniView [1516100247076]: postConstruct |
Info: StatefulOmniView [1516100247076]: exec |
Info: StatefulSession [1516099795164]: exec |
Info: StatelessEjb [1516099795170]: exec |
Info: StatelessEjb [1516099795170]: pseudoState=4 |
Info: StatelessInject [1516099795173]: exec |
Info: StatelessInject [1516099795173]: pseudoState=4 |
Info: Jsf23RequestBean [1516100247066]: preDestroy |
Info: Jsf23RequestBean [1516100247066]: SKIP: WILL NOT force remove() on @EJB statefulEjb ! |
Info: Jsf23RequestBean [1516100247066]: SKIP: WILL NOT force remove() on @Inject statefulInject ! |
Info: Jsf23RequestBean [1516100247066]: SKIP: WILL NOT force remove() on @Inject statefulDepend ! |
Info: Jsf23RequestBean [1516100247066]: SKIP: WILL NOT force remove() on @Inject statefulRequest ! |
Info: Jsf23RequestBean [1516100247066]: SKIP: WILL NOT force remove() on @Inject statefulViewView ! |
Info: Jsf23RequestBean [1516100247066]: SKIP: WILL NOT force remove() on @Inject statefulOmniView ! |
Info: Jsf23RequestBean [1516100247066]: SKIP: WILL NOT force remove() on @Inject statefulSession ! |
Info: StatefulInject [1516100247069]: preDestroy |
Info: StatefulDepend [1516100247070]: preDestroy |
Info: StatefulRequest [1516100247072]: preDestroy
|
Example output with "force remove()" switch ON:
Info: StatefulEjb [1516100349824]: postConstruct |
Info: StatefulInject [1516100349826]: postConstruct |
Info: StatefulDepend [1516100349827]: postConstruct |
Info: Jsf23RequestBean [1516100349824]: postConstruct |
Info: StatefulEjb [1516100349824]: exec |
Info: StatefulInject [1516100349826]: exec |
Info: StatefulDepend [1516100349827]: exec |
Info: StatefulRequest [1516100349829]: postConstruct |
Info: StatefulRequest [1516100349829]: exec |
Info: StatefulViewView [1516100349830]: postConstruct |
Info: StatefulViewView [1516100349830]: exec |
Info: StatefulOmniView [1516100349833]: postConstruct |
Info: StatefulOmniView [1516100349833]: exec |
Info: StatefulSession [1516099795164]: exec |
Info: StatelessEjb [1516099795170]: exec |
Info: StatelessEjb [1516099795170]: pseudoState=5 |
Info: StatelessInject [1516099795173]: exec |
Info: StatelessInject [1516099795173]: pseudoState=5 |
Info: Jsf23RequestBean [1516100349824]: preDestroy |
Info: Jsf23RequestBean [1516100349824]: SKIP: WILL NOT force remove() on @EJB statefulEjb ! |
Info: Jsf23RequestBean [1516100349824]: WILL force remove() on @Inject statefulInject ! |
Info: StatefulInject [1516100349826]: remove |
Info: StatefulInject [1516100349826]: preDestroy |
Info: Jsf23RequestBean [1516100349824]: WILL force remove() on @Inject statefulDepend ! |
Info: StatefulDepend [1516100349827]: remove |
Info: StatefulDepend [1516100349827]: preDestroy |
Info: Jsf23RequestBean [1516100349824]: WILL force remove() on @Inject statefulRequest ! |
ERROR: WELD-000019: Error destroying an instance com.webel.jsf.Jsf23RequestBean@5d16d281 of Managed Bean [class com.webel.jsf.Jsf23RequestBean] with qualifiers [@Default @Any @Named] |
Info: StatefulRequest [1516100349829]: preDestroy
|
That 00019 ERROR message may in fact mean it's indeed doing what you (WELD team) intend. (I read your explanations also at @PreDestroy method throw WELD-000019 exception) |