4 Replies Latest reply on Sep 22, 2011 10:06 AM by smarlow

    Exception The chosen transaction strategy requires access to the JTA TransactionManager

    joydevsingha

      Hi,

       

      As per the JBOSS AS 7 documentation I have configured module.xml for hibernate 3 and deployed persistence.xml file in jar/Meta-Inf/. But during deployment I am getting the below errors

       

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: wealthatlas_persistence] Unable to build EntityManagerFactory

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)

          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)

          at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:143)

          at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:77)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

          ... 4 more

      Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager

          at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:361)

          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)

          at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)

          ... 8 more

       

      Below is my module.xml file

       

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.0" name="org.hibernate.3">

        <resources>

          <resource-root path="hibernate-core.jar"/>

          <!--<resource-root path="ejb3-persistence.jar"/>-->

          <resource-root path="hibernate-annotations.jar"/>

          <resource-root path="hibernate-commons-annotations.jar"/>

          <resource-root path="hibernate-entitymanager.jar"/>

          <resource-root path="javassist.jar"/>

          <resource-root path="dom4j.jar"/>

          <resource-root path="commons-collections-3.1.jar"/>  

          <resource-root path="jta.jar"/>

              <!-- Insert resources here -->

        </resources>

        <dependencies>

           <module name="asm.asm"/>

              <module name="javax.api"/>

              <module name="javax.persistence.api"/>

              <module name="javax.transaction.api"/>

              <module name="javax.validation.api"/>

              <module name="org.antlr"/>

              <module name="org.apache.ant"/>

              <module name="org.apache.commons.collections"/>

              <module name="org.dom4j"/>

              <module name="org.infinispan"/>

              <module name="org.javassist"/>

              <module name="org.jboss.as.jpa.hibernate"  slot="4"/>

              <module name="org.jboss.logging"/>

              <module name="org.slf4j"/>

        </dependencies>

      </module>

       

      Below is the persistence.xml file

       

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence 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" version="2.0">

          <persistence-unit name="wealthatlas_persistence">

              <description>WealthAtlas Persistence Unit.</description>

              <jta-data-source>java:/WealthAtlasDS</jta-data-source>

              <properties>

                  <property name="jboss.as.jpa.providerModule" value="org.hibernate.3"/>

                  <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>

                  <property name="hibernate.archive.autodetection" value="class, hbm"/>

                  <property name="hibernate.show_sql" value="true"/>

                  <property name="jboss.entity.manager.factory.jndi.name" value="java:app/EntityManagerFactory"/>

                  <!--<property name="hibernate.session_factory_name" value="java:app/mySessionFactory" />-->

              </properties>

          </persistence-unit>

      </persistence>

       

      I even tried setting up JTA in persistence.xml with below setting

       

      "transaction-type="JTA"

      and

      <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>

      <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

      <property name="jta.UserTransaction" value="java:comp/UserTransaction"/>

       

      But even the above setting did not work, it was throwing the below error

       

      "org.hibernate.hibernateexception could not locate transactionmanager"