Announcement Announcement Module
No announcement yet.
JTA TransactionManager not available Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JTA TransactionManager not available


    Please help me any one to resolve this below issue.

    We are getting error (attached log.txt)from the container while persisting/merging the entity using entity manager. I am not getting any stack trace from my code.

    As per my understanding from the debug message is Transaction Synchronization Manager removing the current transaction manager, then Transaction Interceptor trying to commit Transaction After Returning.

    Last edited by smaheskumar; Oct 5th, 2008, 01:42 AM.

  • #2
    Fixed-but not reflecting the changes in DB

    I was configured the following properties in the applicationcontext.xml (under sessionFactory) and persistence.xml (under persistence-unit properties).


    Now I have removed from applicationContext.xml and not getting "java.lang.IllegalStateException: JTA TransactionManager not available" stacktrace.

    But not reflecting the persisting and merging entities in the Database. I am getting the following debug message after executing my method.

    Any suggestion? Thanks in advance


    2008-10-05 18:01:38,819 INFO [STDOUT] EXIT: doTransaction
    2008-10-05 18:01:38,819 DEBUG [org.springframework.transaction.interceptor.Transa ctionInterceptor] Completing transaction for [com.bsp.intf.FinancialMgr.doTransaction]
    2008-10-05 18:01:38,819 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] Triggering beforeCommit synchronization
    2008-10-05 18:01:38,819 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] Triggering beforeCompletion synchronization
    2008-10-05 18:01:38,819 DEBUG [ nSynchronizationManager] Removed value [[email protected] ce28] for key [org.springframework.orm.jpa.LocalContainerEntityMa [email protected]] from thread [http-]
    2008-10-05 18:01:38,819 DEBUG [org.springframework.orm.jpa.EntityManagerFactoryUt ils] Closing JPA EntityManager
    2008-10-05 18:01:38,819 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] Initiating transaction commit
    2008-10-05 18:01:38,819 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] Committing Hibernate transaction on Session [[email protected]]
    2008-10-05 18:01:38,835 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] Triggering afterCommit synchronization
    2008-10-05 18:01:38,835 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] Triggering afterCompletion synchronization
    2008-10-05 18:01:38,835 DEBUG [ nSynchronizationManager] Clearing transaction synchronization
    2008-10-05 18:01:38,835 DEBUG [ nSynchronizationManager] Removed value [[email protected] e1aa2] for key [[email protected]] from thread [http-]
    2008-10-05 18:01:38,835 DEBUG [ nSynchronizationManager] Removed value [org.springframework.jdbc.datasource.ConnectionHold [email protected]] for key [[email protected] 1b64b70] from thread [http-]
    2008-10-05 18:01:38,835 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] Closing Hibernate Session [[email protected]] after transaction
    2008-10-05 18:01:38,835 DEBUG [org.springframework.orm.hibernate3.SessionFactoryU tils] Closing Hibernate Session
    Last edited by smaheskumar; Oct 5th, 2008, 08:51 AM.


    • #3
      Why are you using both a SessionFactory and a EntityManager?

      Your persistence.xml settings are interfering with the settings in the application context.xml. Remove all the properties from the persistence.xml and put them in the application context. Also the SessionFactory doesn't (or at least shouldn't!) use the persistence.xml so eveyrthing defined in there is only for the EntityManager. (Which is configured for MySQL and you override for postgresql).

      Also you have configured everything for JTA transactions but are using a HibernateTransactionmanager.

      You also configured annotation based transactions and a TransactionProxyfactoryBean why?

      All in all your current setup is confusing....


      • #4
        I am new to this framework. I have refered in the website and based on my understanding configured everything.

        Actually I want to handle transaction, dirty read and cuncurrent access. Thats why, trying to use EntityManager in JBoss environment.

        Can you please provide your valuable suggestion to use spring with Hibernate?


        • #5
          Unable to build EntityManagerFactory

          Hi Marten,

          I have removed properties from persistence.xml and modified my applicationcontext.xml also. Now I am getthing this below stacktrace.
          Attached xml files for your kind reference.

          ================================================== ====

          Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
          at org.hibernate.impl.SessionFactoryImpl.<init>(Sessi
          at org.hibernate.cfg.Configuration.buildSessionFactor y(
          at org.hibernate.cfg.AnnotationConfiguration.buildSes sionFactory(
          at org.hibernate.ejb.Ejb3Configuration.buildEntityMan agerFactory(
          ... 105 more


          • #6
            I have moved this thread to the Data Access forum, as it is not related to Spring JavaConfig (where it was originally added).


            • #7
              Thanks Chris.

              Actually I want to handle transaction, dirty read and cuncurrent access. Thats why, trying to use EntityManager in JBoss environment.
              Then WHY do you have a SessionFactory and EntityManager configure?

              Also do you really need a JTA transaction manager?

              Your configuration is confusing and doesn't really make clear what you are trying to do. Because there is so much in there (which you probably don't need) it is hard to determine what your current issue actually is....


              • #8
                I want to update a master table and insert in a session table.For this scenario I want to use container manged transaction using entity manager.

                my application server is JBoss, DB is MySQL.


                • #9
                  1) Move the properties from the persistence.xml to your applicationContext
                  2) Remove the SessionFactory and HibernateTransactionManager (orif you need hibernate configure it to use JTA also)
                  3) Make up your mind on what you want to use Annotations or xml for transactions
                  4) Configure a JTATransactionManager

                  Note: I'm going to assume that you are using Spring 2.5.x here.

                  <?xml version="1.0" encoding="UTF-8"?>
                  <beans xmlns=""
                  	<jee:jndi-lookup id="dataSource" jndi-name="java:IrissDS" />
                  	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                  		<property name="dataSource" ref="dataSource" />
                  		<property name="hibernateProperties">
                  	<bean class="" />
                  	<tx:annotation-driven transaction-manager="transactionManager" />
                  	<tx:jta-transaction-manager />
                  	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                  		<property name="dataSource" ref="dataSource"/>
                  		<property name="jpaVendorAdapter">
                  			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                  				<property name="showSql" value="true" />
                  				<property name="database" value="MYSQL"/>
                  		<property name="jpaProperties">
                  <persistence version="1.0" xmlns="" xmlns:xsi="" xsi:schemaLocation=" ">
                  	<persistence-unit name="bspEntityMgr" transaction-type="JTA" >
                  Note: can be that you still need to include a jta-datasource here, haven't actually tested it.
                  Note2: Why do you have an ORM and Classes configured?! Normally you use either a orm.xml OR classes not both.
                  Last edited by Marten Deinum; Oct 6th, 2008, 01:54 AM.


                  • #10
                    Error creating bean with name 'sessionFactory'

                    Thank you very much for your help.

                    I have changed my configuration as you suggested. Now I am facing error in sessionFactory creation. I think this is a class loader issue. But all the necessary jars are available at web-inf\lib(attached the lib folder screenshot), even I'm getting this below error. Kindly help me, If you have any suggestion.

                    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: TransactionFactory class not found: org.hibernate.transaction.JTATransactionFactory

                    I am using Jboss 4.0.3SP1 and spring 2.5.5


                    • #11
                      We are getting the same error while doing the deployment on Weblogic.
                      We have a application which uses JPA as a transaction manager, but there is certain services of the aplication which classifies for distributed transactions sinces we are using JMS part with this.

                      We want to use WebLogicJtaTransactionManager for this but as soon as we do the transaction-type in persistence.xml as 'JTA' and do all the spring config and try to deploy it is giving this error.

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

                      Attaching the config and perrsistence file.

                      Please help and let us know where we are doing wrong.

                      Thanks and advance.