The chosen transaction strategy requires access to the JTA TransactionManager or Unable to build EntityManagerFactory

后端 未结 2 1241
执念已碎
执念已碎 2021-02-09 04:19

I am using Spring 2.0.6 and Hibernate 3.2.x on apache tomcat5.5,now we planed to changed our hybernate mapping files into hybernate+jpa support mapping files. for that we cr

相关标签:
2条回答
  • 2021-02-09 04:25

    For those who are using Jboss AS, this configuration could be used:

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

    Solution extracted from: http://www.gregbugaj.com/?p=172

    0 讨论(0)
  • 2021-02-09 04:34

    First of all, you're creating both a Hibernate SessionFactory and a JPA EntityManagerFactory. That does not make very much sense unless you have a very odd setup, and you should very likely throw out the SessionFactory configuration. You can either configure plain vanilla Hibernate, or you can configure JPA, you don't need both.

    The creation of the entity manager factory fails because you specified JTA as the transaction type, but the JTA transaction manager lookup class is not defined. (You defined it in the Hibernate SessionFactory config, but not in your JPA config.)

    Add this to your persistence.xml:

    <persistence-unit name="payhub" transaction-type="JTA">
    
        ...
    
        <properties>
            <property name="hibernate.transaction.manager_lookup_class" 
                value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/>
        </properties>               
    </persistence-unit>
    
    0 讨论(0)
提交回复
热议问题