• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JBoss 4.2 + Hibernate 3 + Java - NullPointerException + persistence.xml

Mate Nyitrai
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I got a problem: Im using Jboss 4.2 and Hibernate 3. I got a NullPointerExceptionon at the line with the manager as I open my JavaWeb-Project(JSP) in the browser.
The persistence.xml file is in the META-INF Directory.

This is in the SimulateDB class as global variable:
@PersistenceContext(unitName = "hibernateTest")
private EntityManager manager;
Methode in the same class:
public synchronized Benutzer login(Benutzer user, HttpSession session) {
Query q = manager.createNamedQuery("Benutzer.login");
q.setParameter("username", user.getBenutzername());
q.setParameter("password", user.getPasswort());
Benutzer benutzer = (Benutzer) q.getSingleResult();
if (benutzer != null) {
return benutzer;
return null;

@Table(name = "Benutzer")
@NamedQuery(name = "Benutzer.findAll", query = "from user b"),
@NamedQuery(name = "Benutzer.login", query = "from user b where b.benutzername = username")
public class Benutzer extends AbstractLibraryBean {
private int id;
private String benutzername;
private String passwort;
private String name;

I can't realize what the problem is, the class within the EntityManager is a Singelton and the methode within the Query will call as heer:

Any Idea?

Thank you!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic