aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How to inject one EJB into another EJB in the same application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to inject one EJB into another EJB in the same application" Watch "How to inject one EJB into another EJB in the same application" New topic
Author

How to inject one EJB into another EJB in the same application

Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 481
    
    1

Hello everybody!

[size=12]I am developing simple application to understand better JMS. It turned out that I know very little of EJB injection too.
I am desperate after this day trying to inject one Message-Driven Bean into another stateful bean. Each attempt to deploy my app I have only mistakes. As I remember the first mistake of this was NameNotFoundException and after that long range of Exception subclasses.
Here is my mdb which has to be injected into another bean within the same folder even:

Here is my ejb that injects above mdb:


I have tried all possible attributes from @EJB. I tried to change web.xml as I found on the Internet. What I found is here:

Unfortunately this piece of code only encreased range of my mistakes! Also I tried to add there <lookup-name> element, then <mapped-name> but vainly!

Can anybody advise me what to set in my web.xml or EJBs to have my MDB injected into my stateful bean. I tried also to change stateful bean to stateless but it didn't make any difference! I tried to move from @EJB to @Resource annotation but it didn't help too.

Thank you very much for any ideas!
[/size]


True person is moral, false is right!
Marcin Strzyz
Greenhorn

Joined: Feb 25, 2012
Posts: 5
As far as I know it is not possible to inject MDB instance into another bean because MDB are invisible for the clients. You can only get a reference to a Queue or Topic the MDB is listening.
 
 
subject: How to inject one EJB into another EJB in the same application
 
Similar Threads
exception accessing ejb from servlet in OCj4
ejb-local-ref and ejb-ref
OpenEJB, DI Overriding annotation with deployment descriptor
NameNotFoundException Name "comp/env /ejb/HelloBeanRemote" not found
ejb reference in deployment descriptor (without annotations )