when I try to inject the EntityManager, it is always null without throwing an exception. It doesn't matter where the persistence.xml is placed, if it is empty or missing; this file seems completly to be ignored. My persistence.xml is placed in src/main/resources/META-INF/. I try to get it run in a Jetty now for 2 days, but there is no way. I would really appreciate your help.
My producer:
@Singleton
public class ApplicationResources {
@PersistenceUnit
private EntityManagerFactory emManagerFactory;
@Produces
public EntityManagerFactory produces() {
System.err.println("produces " + emManagerFactory);
return emManagerFactory;
}
}
My DAO
@Stateless
public class AverageCountryPricesDAO {
@Inject
private EntityManagerFactory emManagerFactory;
public AverageCountryPricesDAO() {
System.err.println("construct DAO");
}
public void testit() {
System.err.println("emManagerFactory: " + emManagerFactory);
}
}
My pom.xml
<dependencies>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.8</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.8.Final</version>
</dependency>
<!-- weld-servlet JAR is manually removed from WAR file -->
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet</artifactId>
<version>2.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-plus</artifactId>
<version>8.1.7.v20120910</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>8.1.7.v20120910</version>
</dependency>
</dependencies>
Thanks in advance, Tim