EJB injection in Glassfish webapp

Posted by g051051 on Stack Overflow See other posts from Stack Overflow or by g051051
Published on 2010-05-18T18:49:46Z Indexed on 2010/05/18 23:10 UTC
Read the original article Hit count: 218

Filed under:
|
|
|
|

I've got an app that is trying to use @EJB annotation to inject remote references to EJBs in my ejb.jar file. I'm getting inconsistent results. In one case, I have a listener in web.xml that gets called and apparently has the EJB injected correctly, since I can see it connecting to the EJB and calling methods on it. In another class (a struts2 action) I get NPE when it tries to access the EJB reference. As far as I can tell, they're identical calls, in Java classes that live in the same .war file.

As a work around, I added code in the constructor to lookup the EJBs by their global JNDI names, and it works fine. I just can't figure out why one @EJB works and not another.

© Stack Overflow or respective owner

Related posts about glassfishv3

Related posts about ejb3.1