This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Why doesn`t my @PersistenceContext & @EJB work??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Why doesn`t my @PersistenceContext & @EJB work??? " Watch "Why doesn`t my @PersistenceContext & @EJB work??? " New topic

Why doesn`t my @PersistenceContext & @EJB work???

Derick Potgieter
Ranch Hand

Joined: Feb 19, 2004
Posts: 53
Hi Guys,

i`m having a bit of a hard day, getting my annotations to work. I`m using glassfish b48.

My EJB3.0 entity`s deploy fine, including a stateless session bean that is accessing these entity beans, i deploy this in a seperate jar.

Then i have a webservice (jax-ws 2.0) that access the session bean and calls the methods on it. (seperate deploy).
When i write all the old jndi lookup code, it works fine.
but not when i use the annotation, aswell as for @PersistenceContext EntityManager em; I can once again get a reference to it if use the EntityManagerFactory emf = Persistence.createEntityManagerFactory("postgres");

even if i specify the unitName in the annotation i cant seem to get hold of the Reference. and this is also my only persistence unit in the app.

o just for safety sake...i can persist and retrieve entity`s if i get a reference to the EntityManager.

Any reason why it doesnt work would help.

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24193

Not advanced Java. Moving to EJB and other J2EE Technologies.

[Jess in Action][AskingGoodQuestions]
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

When you try to use @EJB and the like, you are including the name, right? like

@EJB (name=blahblahblah) Or is the name in quotes?


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Derick Potgieter
Ranch Hand

Joined: Feb 19, 2004
Posts: 53
the name is in quotes...

has to be as far as i know??
I agree. Here's the link:
subject: Why doesn`t my @PersistenceContext & @EJB work???
jQuery in Action, 3rd edition