This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem while injecting EntityManager

 
Mona Yehia
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an EJB bean TestBean



I tried using EntityManager to create a query, it throws null pointer exception.
Tried getting entityManager from EntityManagerFactory also null pointer exception, I don't know what's missing, here is my persistence.xml:



And yes it is located in META-INF folder.
Any help please??

The exception:
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your injection doesn't seem to be the problem, otherwise the NullPointerException would have been caused by your code, but instead it comes from inside the EntityManager.
 
Mona Yehia
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the problem
The JTA platform property was missing, I added this to my persistence.xml as I am using glassfish & it worked
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!