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

回眸只為那壹抹淺笑 提交于 2019-11-27 14:43:52

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!