Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EntityManager not getting injected in EJB, resulting in NullPointerException

 
Shilpa Mishra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shilpa Mishra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To which application server are you deploying, and what does the structure of your deployment look like?
 
Shilpa Mishra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic