This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes @EJB injection from different jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "@EJB injection from different jar" Watch "@EJB injection from different jar" New topic

@EJB injection from different jar

Mattia Battiston

Joined: Mar 23, 2009
Posts: 7
I'm having a problem with EJB injection, hopefully someone here will be able to help me.

I've got a jar with an EJB in there; this is its code:

From other classes in the same jar I can inject it simply like this:

Here comes the problems: I'm actually deploying this jar in an ear, and in this ear I've also got a war with some JSF pages and related java backing beans.
What I want to do is to inject my TravelAgentBean in a page's backing bean (e.g. CreateCabinBackingBean), but the same code as above doesn't work:

However, this code works:

I'm deploying on Jboss 4.2.2. I'm quite new both with JSF and EJB, so probably there's something I'm missing...can someone please give me an advice on how to make the dependency injection work?

Thank you very much

Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30138

See this JavaRanch post for why it doesn't work in JBoss for JSF.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Mattia Battiston

Joined: Mar 23, 2009
Posts: 7
ok, that's clear now, thank you very much. Mattia
Don't get me started about those stupid light bulbs.
subject: @EJB injection from different jar
Similar Threads
NamingException: Could not dereference object - EJB 3.0 workbook ex05-2
Hi, why am I getting this exception on console
JPA using Hibernate - Entity Manager doubts
ejb 3.0 lookup
TestEJB not bound