[jboss-jira] [JBoss JIRA] Commented: (JBAS-8818) CDI injection not working in WebListeners
Marius Bogoevici (JIRA)
jira-events at lists.jboss.org
Thu Jan 20 12:49:49 EST 2011
[ https://issues.jboss.org/browse/JBAS-8818?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12576877#comment-12576877 ]
Marius Bogoevici commented on JBAS-8818:
----------------------------------------
Actually, this is a combination of two problems: when the listener is started, the EJB is not available in JNDI yet, which causes the injection to fail. The failure (a Weld CreationException) is then swallowed by JBoss Web, which skips the injection process, but still instantiates the Listener.
This is happening because the Web container is started before the EJB container is started (since there is no explicit hard dependency between them - Switchboard handles @EJB references as dependencies, but not @Inject references).
There are a couple of workarounds to this: either using an @EJB reference directly, or using an EE resource producer field (both causing the EJB container to start first).
Ideally, this should be fixed by ensuring that EJB refs are available before the web container is started, or in the least, by treating @Inject references that resolve to EJBs in a similar way to @EJB. Unfortunately, this is going to happen only in a later version of JBoss AS.
> CDI injection not working in WebListeners
> -----------------------------------------
>
> Key: JBAS-8818
> URL: https://issues.jboss.org/browse/JBAS-8818
> Project: JBoss Application Server
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Weld/CDI
> Affects Versions: 6.0.0.Final
> Reporter: Nicklas Karlsson
> Assignee: Marius Bogoevici
>
> CDI injection is not performed for WebListeners, e.g.
> @WebListener
> public class BugListener implements HttpSessionListener
> {
> @Inject
> BeanManager beanManager;
> ...
> }
> Will have beanManager==null when the methods are hit
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list