[jboss-user] [EJB3] - @EJB vs. InitialCotext.doLookup(...)

Joachim Heidenreich do-not-reply at jboss.com
Mon Mar 28 08:56:23 EDT 2011


Joachim Heidenreich [http://community.jboss.org/people/carcophan] created the discussion

"@EJB vs. InitialCotext.doLookup(...)"

To view the discussion, visit: http://community.jboss.org/message/595940#595940

--------------------------------------------------------------
Hello,
 
 I have a question about context lookups and dependency injection regarding the following scenario:
 
 I'm using JBoss 6.0, JSF 2.1 (Mojarra), EJB3.1
 I have and ejb jar and a war archive packaged together in an ear.
 My ejb-jar contains a stateless, no interface (local) session bean.
 My war has a session scoped managed bean.
 
 Inside my managed bean, I use the @EJB annotation to inject an instance of my no-interface session bean - works like a charm!
 However, when I deploy the ejb-jar and the war archives separately (without the ear) I get an error, stating that "Could not resolve @EJB reference... ". However when I remove the @EJB annotation in my managed bean and do a "InitialContext.doLookup("...") instead, I get no errors and everything isfine.
 
 Why doesn't dependency Injection using the @EJB annotation work when deploying the artifacts separately but a manual lookup does?
 (I first deploy my ejb-jar and afterwards I deploy the war.)
 
 Does anyone have a clue?
 
----
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/595940#595940]

Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110328/3b6bef08/attachment-0001.html 


More information about the jboss-user mailing list