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

  • JTA TransactionManager not available

    Hi,

    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.

    Attachments
    =========
    log.txt
    orm.xml
    persistence.xml
    applicationcontext.xml
    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).

    hibernate.transaction.factory_class
    hibernate.transaction.manager_lookup_class
    hibernate.current_session_context_class

    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

    ===========log===========

    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 [org.springframework.transaction.support.Transactio nSynchronizationManager] Removed value [org.springframework.orm.jpa.EntityManagerHolder@45 ce28] for key [org.springframework.orm.jpa.LocalContainerEntityMa nagerFactoryBean@184bc9b] from thread [http-0.0.0.0-8080-1]
    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 [org.hibernate.impl.SessionImpl@15a5aff]
    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 [org.springframework.transaction.support.Transactio nSynchronizationManager] Clearing transaction synchronization
    2008-10-05 18:01:38,835 DEBUG [org.springframework.transaction.support.Transactio nSynchronizationManager] Removed value [org.springframework.orm.hibernate3.SessionHolder@e e1aa2] for key [org.hibernate.impl.SessionFactoryImpl@7544a6] from thread [http-0.0.0.0-8080-1]
    2008-10-05 18:01:38,835 DEBUG [org.springframework.transaction.support.Transactio nSynchronizationManager] Removed value [org.springframework.jdbc.datasource.ConnectionHold er@39a07] for key [org.jboss.resource.adapter.jdbc.WrapperDataSource@ 1b64b70] from thread [http-0.0.0.0-8080-1]
    2008-10-05 18:01:38,835 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] Closing Hibernate Session [org.hibernate.impl.SessionImpl@15a5aff] 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.

    Comment


    • #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....

      Comment


      • #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?

        Comment


        • #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 onFactoryImpl.java:361)
          at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1327)
          at org.hibernate.cfg.AnnotationConfiguration.buildSes sionFactory(AnnotationConfiguration.java:867)
          at org.hibernate.ejb.Ejb3Configuration.buildEntityMan agerFactory(Ejb3Configuration.java:669)
          ... 105 more

          Comment


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

            Comment


            • #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....

              Comment


              • #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.

                Environment
                my application server is JBoss, DB is MySQL.

                Comment


                • #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.

                  Code:
                  <?xml version="1.0" encoding="UTF-8"?>
                  <beans xmlns="http://www.springframework.org/schema/beans"
                  	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                  	xmlns:aop="http://www.springframework.org/schema/aop"
                  	xmlns:tx="http://www.springframework.org/schema/tx"
                  	xmlns:jee="http://www.springframework.org/schema/jee"
                  	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
                  						http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
                  						http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                  						http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
                  	
                  	<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">
                  			<value>
                  				hibernate.dialect=org.hibernate.dialect.MySQLDialect
                  				hibernate.show_sql=true
                  				hibernate.connection.isolation=2
                  				hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
                  				hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory				
                  				hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
                  				hibernate.current_session_context_class=jta
                  				hibernate.jdbc.batch_size=5
                  				hibernate.transaction.flush_before_completion=true
                  			</value>
                  		</property>
                  	</bean>
                  
                  	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
                  		
                  	<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"/>
                  			</bean>
                  		</property>
                  		<property name="jpaProperties">
                  			<value>
                  				hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory				
                  				hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
                  				hibernate.current_session_context_class=jta
                  			</value>
                  		</property>
                  	</bean>
                  </beans>
                  persistence.xml
                  Code:
                  <persistence version="1.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_1_0.xsd ">
                  	<persistence-unit name="bspEntityMgr" transaction-type="JTA" >
                  		<mapping-file>META-INF/orm.xml</mapping-file>		
                  		<class>com.bsp.entity.AccountMaster</class>
                  		<class>com.bsp.entity.AccountSession</class>				
                  		<exclude-unlisted-classes>false</exclude-unlisted-classes>
                  	</persistence-unit>
                  </persistence>
                  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.

                  Comment


                  • #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

                    Comment


                    • #11
                      Hi,
                      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.
                      Pushpendra

                      Comment

                      Working...
                      X