Using JPA2 in Tomcat 6: @PersitenceContext doesn't work, EntityManager is null

前端 未结 1 622
鱼传尺愫
鱼传尺愫 2020-12-17 00:27

I am using JSF2 with Pure JPA2. But the problem is with entityManager,

@PersistenceContext
private EntityManager entityManager;

Here enti

相关标签:
1条回答
  • 2020-12-17 00:50

    Tomcat is not a Java EE container, so there are limitations related to container managed factories and dependency injection. Among others, you need to manually create the EntityManagerFactory and the EntityManager.

    Hibernate documentation isn't clear on that, so here's the Eclipselink one: Tomcat/JPA tutorial. Check the "Limitations to JPA" section, this applies as good to Hibernate.

    See also:

    • Best practice to get EntityManagerFactory
    0 讨论(0)
提交回复
热议问题