I can not build my entity manager factory and the error I get is "chosen transaction strategy requires access to the JTA Transaction Manager". Can anyone advise what i have to configure to get past this? FYI I'm using Jboss 6, no spring.
Here is my persistance.xml
<persistence version="2.0" 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_2_0.xsd">
<persistence-unit name="AvengersPU" transaction-type="JTA">
<jta-data-source>java:/jdbc/thor_ds</jta-data-source>
<class>avenger.Grouptable</class>
<class>avenger.MyUser</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
</persistence>
Here is partial stacktrace...
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: AvengersPU] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) [:3.6.6.Final]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57) [:3.6.6.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48) [:1.0.0.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32) [:1.0.0.Final]
at avenger.Utils.getEntityManager(Utils.java:49) [:]
at avenger.UserBean.updateUserList(UserBean.java:136) [:]
at avenger.UserBean.startup(UserBean.java:43) [:]
... 68 more
Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:390) [:3.6.6.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872) [:3.6.6.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906) [:3.6.6.Final]
... 74 more
Full stack trace is here: http://pastebin.ca/2166417
Here is an non ideal answer which I will use in the meanwhile.
specify a non jta datasource:
<non-jta-data-source>java:/jdbc/thor_ds</non-jta-data-source>
change transaction type from JTA to RESOURCE_LOCAL
<persistence-unit name="AvengersPU" transaction-type="RESOURCE_LOCAL">
Here is a discussion on the subject:
来源:https://stackoverflow.com/questions/11300316/can-not-create-entitymanager-factory-bc-jta-tx-manager-requiered