-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: chosen transaction strategy requires JTA TransactionManager
PostPosted: Wed May 10, 2006 1:13 pm 
Newbie

Joined: Wed May 10, 2006 12:48 pm
Posts: 7
Location: Munich
I am totaly new to Hibernate and stuck on this problem.

I want to create an extended EntityManager (J2SE). I get the following exception. I am clueless why it wants a JTA TransactionManager, I thought that JDBC is default.

javax.persistence.PersistenceException: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
at com.siemens.smarthome.AquireEntityManager.setUp(AquireEntityManager.java:12)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:326)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:522)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:650)
at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188)
... 14 more


persistence.xml
Code:
<persistence>
    <persistence-unit name="smarthome">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
             <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>

        <property name="hibernate.max_fetch_depth" value="4"/>
       <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
       <property name="hibernate.connection.username" value="sa"/>
       <property name="hibernate.connection.password" value=""/>
       <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:aname"/>
       <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>

<!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>
       
<!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">create</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
       
       
        </properties>
    </persistence-unit>
</persistence>



Code to create EM.
Code:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("smarthome");
      
      EntityManager em = emf.createEntityManager();


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 2:42 am 
Newbie

Joined: Wed May 10, 2006 12:48 pm
Posts: 7
Location: Munich
The answer to this problem was in second chapter of documentation. I fill stupid now, I can't belive I missed it yesterday.

Some exerpts:

The entity manager type (JTA or resource-local) is defined at configuration time, when setting up the entity manager factory.

The configuration for entity managers both inside an application server and in a standalone application reside in a persistence archive. A persistence archive is a JAR file which must define a persistence.xml file that resides in the META-INF folder.

Transaction type is chosen in transaction-type attribute of persistence-unit element. Either JTA or RESOURCE_LOCAL (default JTA).
Code:
<persistence-unit name="smarthome" transaction-type="RESOURCE_LOCAL">


Top
 Profile  
 
 Post subject: Re: chosen transaction strategy requires JTA TransactionManager
PostPosted: Thu Nov 18, 2010 2:31 am 
Newbie

Joined: Tue Nov 02, 2010 10:55 am
Posts: 17
hi friend i think you got solution for this issue
Quote:
"chosen transaction strategy requires JTA TransactionManager"

I am also facing the same problem i created anew thread for this could you see that and help me
Quote:
https://forum.hibernate.org/viewtopic.php?f=1&t=1008248


Top
 Profile  
 
 Post subject: Re: chosen transaction strategy requires JTA TransactionManager
PostPosted: Fri Jun 01, 2012 10:00 am 
Newbie

Joined: Fri Jun 01, 2012 9:55 am
Posts: 2
Hi,

You should add a new property in the persistence.xml file

If you are using JBoss:

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

otherwhise you can use this one :

<property name="hibernate.transaction.manager_lookup_class" value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/>

Hope it helps you.


Top
 Profile  
 
 Post subject: Re: chosen transaction strategy requires JTA TransactionManager
PostPosted: Fri Jun 01, 2012 10:02 am 
Newbie

Joined: Fri Jun 01, 2012 9:55 am
Posts: 2
Code:

<!-- persistence.xml file -->
<property name="hibernate.transaction.manager_lookup_class" value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/>

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.