This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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


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: 505
    
    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.
 
GeeCON Prague 2014
 
subject: How to inject one EJB into another EJB in the same application