PersistenceContext « EntityManager « JPA Q&A





1. PersistenceContext EntityManager injection NullPointerException    stackoverflow.com

I have a war containing the following:

META-INF/MANIFEST.MF
WEB-INF/classes/META-INF/persistence.xml
WEB-INF/classes/com/test/service/TestServlet.class
WEB-INF/classes/com/test/service/TestEntity.class
WEB-INF/classes/jndi.properties
WEB-INF/classes/postgresql-ds.xml
WEB-INF/jboss-web.xml
WEB-INF/web.xml
index.jsp
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
    <persistence-unit name="test">
      ...

2. @PersistenceContext, EntityManager and NullPointerException    forum.hibernate.org

Newbie Joined: Wed Apr 13, 2011 10:03 am Posts: 3 hi, I know it's a problem widely discussed, but I read forums from two days and everything looks correct, please help me. I have netbeans 7, tomcat 7, hibernate 3.6.3 and JavaServer Faces 2. this is the structure of the project: Code: ./src: conf java ./src/conf: MANIFEST.MF persistence.xml ./src/java: ...