File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Different ways of dependency injection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Different ways of dependency injection" Watch "Different ways of dependency injection" New topic
Author

Different ways of dependency injection

Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
Hello,

I have a question about Context lookups and dependency Injection regarding the following scenario:

I'm using JBoss 6, JSF 2.0, EJB 3.1
I have and ejb jar and a war archive packaged together in an ear.
My ejb-jar contains a stateless, no interface 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!
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("..."), I get NO errors and everything is fine.

Why doesn't dependency Injection using the EJB annotation work when deploying the artifacts sepeparately but a manual lookup does?
(I first deploy my ejb-jar and afterwards I deploy the war.)

Does anyone have a clue?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Different ways of dependency injection
 
Similar Threads
how to access one ejb with local interface from different application deployed in same server.
Jboss 5 - @Resource dataSource versus direct lookup in Session Bean
JEE5 bean and war deployment
Can't reach NamedQuery
Dependency Injection Problem !!!