Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Need help with @EJB dependency injection null pointer

meatwadMar 2 2011 — edited Mar 4 2011
I have an application in an ear file that contains 2 modules. One is a web component war and the other is an ejb jar.
appname.ear
+-webclient.war
+-webbean.jar
I have declared my bean with a @Stateless annotation:
@Stateless
public class EchoBean {}
And added a dependency with @EJB in a servlet in my web module:
@EJB(lookup="java:app/webbean/EchoBean")
private EchoBean _echo;
Everything compiles but when I run, this object always comes up null. Using a JNDI lookup on the InitialContext I can successfully get the bean via "java:app/webbean/EchoBean". But using that as the lookup attribute in the @EJB also fails. What could I be doing wrong?
This post has been answered by gimbal2 on Mar 4 2011
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 1 2011
Added on Mar 2 2011
9 comments
1,647 views