createEntityManager throws java.lang.NullPointerException at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus

后端 未结 2 646
粉色の甜心
粉色の甜心 2020-12-03 14:47

I\'m getting this stack trace when I deploy my hibernate app

java.lang.NullPointerException
    at org.hibernate.engine.transaction.internal.jta.JtaStatusHel         


        
相关标签:
2条回答
  • 2020-12-03 15:23

    If you're using Hibernate 4 and trying to create a EntityManagerFactory manually (or SessionFactory) declared as <jta-datasource>, there is a property you must set on your persistence.xml called hibernate.transaction.jta.platform. For using on JBoss 7

    <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
    

    I found about this property at Hibernate Docs

    0 讨论(0)
  • 2020-12-03 15:24

    Stacktrace clearly indicates that Hibernate cannot join JTA transaction. Moreover, comination of <jta-data-source> and Persistence.createEntityManagerFactory() looks strange - JTA-capable EntityManager is usually created by application server and obtained from it via JNDI.

    If you actually want to use resource-local transactions rather than JTA, you need to declare <non-jta-data-source> instead.

    0 讨论(0)
提交回复
热议问题