Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]
 
Marcin Strzyz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic