This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes EJB EntityManager results in NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB EntityManager results in NullPointerException" Watch "EJB EntityManager results in NullPointerException" New topic
Author

EJB EntityManager results in NullPointerException

Ibragim Gapuraev
Greenhorn

Joined: Mar 21, 2011
Posts: 24
I have an error that I cannot logically understand. I am implementing RSS processing app. The logic is that user takes link of some RSS feed and adds to database. If the feed already exist in database, it takes the id of feed and adds it to subscriptions of the user. Here is the code:



However, if user added a feed, another user cannot add it and there is the error:




I just dont see why would it fail. One of my opinion is that possibly, EntityManager somehow is null. But, in first part of if statement it works.

I tried to use EntityManager find method, it resulted same error. So, definitely, EntityManager is somehow null in second part of if statement.

Thanks for all the help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: EJB EntityManager results in NullPointerException
 
Similar Threads
Problem Persisting Entity In Hibernate
@EJB and @ PersistenceContext not working in JBOSS.5.1.0.GA?
Confused about interfaces
how to update OneToMany
JPA 2.0/EclipseLink how to access "internal exception" type?