jQuery in Action, 2nd edition*
The moose likes EJB and other Java EE Technologies and the fly likes EntityManager not getting injected in EJB, resulting in NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EntityManager not getting injected in EJB, resulting in NullPointerException" Watch "EntityManager not getting injected in EJB, resulting in NullPointerException" New topic
Author

EntityManager not getting injected in EJB, resulting in NullPointerException

Shilpa Mishra
Greenhorn

Joined: Oct 08, 2012
Posts: 4
am new to J2EE and have been trying to resolve this issue from almost a week. This is the code in my session bean where in I am getting a NullPointerException. Found out that the entity manager is not getting injected. Can anyone pllllzzzz lemme know how to resolve it.

The code from session bean:

Thanks in advance
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

Hi,
Please UseCodeTags when posting code. Click on the link to understand how to do that.

You have indicated you have a NullPointerException. Please provide the stack trace as that would point to the line where this happens: TellTheDetails.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Shilpa Mishra
Greenhorn

Joined: Oct 08, 2012
Posts: 4
Hi,
Sorry am new to the forum, added the code tags.
This is the last 2 lines from the stack trace.
SEVERE: java.lang.NullPointerException
at session.UserFacade.validateUser(UserFacade.java:56)
I am getting the Null Pointer Exception in this line

From the msgs that I have printed out, it shows that em is null.
Could you please lemme know what am I missing

Thanks,

Ranganathan Kaliyur Mannar wrote:Hi,
Please UseCodeTags when posting code. Click on the link to understand how to do that.

You have indicated you have a NullPointerException. Please provide the stack trace as that would point to the line where this happens: TellTheDetails.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1761
    
    7

To which application server are you deploying, and what does the structure of your deployment look like?


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Shilpa Mishra
Greenhorn

Joined: Oct 08, 2012
Posts: 4
Hey Guys,
Solved it.. Had not injected EJB at managed bean level. Thats where the prob was .



Jelle Klap wrote:To which application server are you deploying, and what does the structure of your deployment look like?
 
jQuery in Action, 2nd edition
 
subject: EntityManager not getting injected in EJB, resulting in NullPointerException