java.lang.IllegalStateException: Active Spring transaction synchronization or jtaTransactionManager on LocalSessionFactoryBean plus active JTA transaction required

Spring JIRA | Victor | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    In the afterPropertiesSet call of LocalSessionFactoryBean, the configTimeTransactionManagerHolder is set after mappingLocations, which is incorrect because mappingLocations will incur hibernate type mapping and the LobType will initialized with "null" jtaManager instance, and later cause the attached error. Moving the if (this.jtaTransactionManager != null) { // set Spring-provided JTA TransactionManager for Hibernate cache callbacks config.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, LocalTransactionManagerLookup.class.getName()); configTimeTransactionManagerHolder.set(this.jtaTransactionManager); } to the top of afterPropertiesSet will fix this bug. =================== [9/8/04 14:39:11:047 EDT] 7e2ed625 SystemOut U ERROR [ORB.thread.pool:1] (SessionFactoryUtils.java:743) - beforeCommit callback threw exception java.lang.IllegalStateException: Active Spring transaction synchronization or jtaTransactionManager on LocalSessionFactoryBean plus active JTA transaction required at org.springframework.orm.hibernate.support.AbstractLobType.nullSafeSet(AbstractLobType.java:169) at net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118) at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:393) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:466) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442) at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236) at org.springframework.orm.hibernate.SessionFactoryUtils$SpringSessionSynchronization.beforeCommit(SessionFactoryUtils.java:655) at org.springframework.orm.hibernate.SessionFactoryUtils$JtaSessionSynchronization.beforeCompletion(SessionFactoryUtils.java:740) at com.ibm.ejs.jts.jta.TransactionImpl.before_completion(TransactionImpl.java:966) at com.ibm.ejs.jts.jts.CoordinatorImpl$Sync.beforePrepare(CoordinatorImpl.java:692) at com.ibm.ejs.jts.tran.EventCallback.executeCallback(EventCallback.java:166) at com.ibm.ejs.jts.tran.EventCallback.executeCallbackTree(EventCallback.java:132) at com.ibm.ejs.jts.tran.EventPrepare.ExecuteBeforePrepareCallbacks(EventPrepare.java:297) at com.ibm.ejs.jts.tran.EventPrepare.event_LocalPrepareWork(EventPrepare.java:277) at com.ibm.ejs.jts.tran.EventPrepare.event_BecomeCoordinator(EventPrepare.java:960) at com.ibm.ejs.jts.tran.EventControl.event_EndTopLevel(EventControl.java:295) at com.ibm.ejs.jts.tran.TrecInterface.end(TrecInterface.java:88) at com.ibm.ejs.jts.jts.TerminatorImpl.commit(TerminatorImpl.java:89) at com.ibm.ejs.jts.jts.CurrentImpl.commit(CurrentImpl.java:200) at com.ibm.ejs.jts.jts.CurrentSet.commit(CurrentSet.java:256) at com.ibm.ejs.jts.jts.Current.commit(Current.java:71) at com.ibm.ejs.jts.jta.UserTransactionImpl.commit(UserTransactionImpl.java:182) at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:532) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:373) at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:241) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)

    Spring JIRA | 1 decade ago | Victor
    java.lang.IllegalStateException: Active Spring transaction synchronization or jtaTransactionManager on LocalSessionFactoryBean plus active JTA transaction required
  2. 0

    In the afterPropertiesSet call of LocalSessionFactoryBean, the configTimeTransactionManagerHolder is set after mappingLocations, which is incorrect because mappingLocations will incur hibernate type mapping and the LobType will initialized with "null" jtaManager instance, and later cause the attached error. Moving the if (this.jtaTransactionManager != null) { // set Spring-provided JTA TransactionManager for Hibernate cache callbacks config.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, LocalTransactionManagerLookup.class.getName()); configTimeTransactionManagerHolder.set(this.jtaTransactionManager); } to the top of afterPropertiesSet will fix this bug. =================== [9/8/04 14:39:11:047 EDT] 7e2ed625 SystemOut U ERROR [ORB.thread.pool:1] (SessionFactoryUtils.java:743) - beforeCommit callback threw exception java.lang.IllegalStateException: Active Spring transaction synchronization or jtaTransactionManager on LocalSessionFactoryBean plus active JTA transaction required at org.springframework.orm.hibernate.support.AbstractLobType.nullSafeSet(AbstractLobType.java:169) at net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118) at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:393) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:466) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442) at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236) at org.springframework.orm.hibernate.SessionFactoryUtils$SpringSessionSynchronization.beforeCommit(SessionFactoryUtils.java:655) at org.springframework.orm.hibernate.SessionFactoryUtils$JtaSessionSynchronization.beforeCompletion(SessionFactoryUtils.java:740) at com.ibm.ejs.jts.jta.TransactionImpl.before_completion(TransactionImpl.java:966) at com.ibm.ejs.jts.jts.CoordinatorImpl$Sync.beforePrepare(CoordinatorImpl.java:692) at com.ibm.ejs.jts.tran.EventCallback.executeCallback(EventCallback.java:166) at com.ibm.ejs.jts.tran.EventCallback.executeCallbackTree(EventCallback.java:132) at com.ibm.ejs.jts.tran.EventPrepare.ExecuteBeforePrepareCallbacks(EventPrepare.java:297) at com.ibm.ejs.jts.tran.EventPrepare.event_LocalPrepareWork(EventPrepare.java:277) at com.ibm.ejs.jts.tran.EventPrepare.event_BecomeCoordinator(EventPrepare.java:960) at com.ibm.ejs.jts.tran.EventControl.event_EndTopLevel(EventControl.java:295) at com.ibm.ejs.jts.tran.TrecInterface.end(TrecInterface.java:88) at com.ibm.ejs.jts.jts.TerminatorImpl.commit(TerminatorImpl.java:89) at com.ibm.ejs.jts.jts.CurrentImpl.commit(CurrentImpl.java:200) at com.ibm.ejs.jts.jts.CurrentSet.commit(CurrentSet.java:256) at com.ibm.ejs.jts.jts.Current.commit(Current.java:71) at com.ibm.ejs.jts.jta.UserTransactionImpl.commit(UserTransactionImpl.java:182) at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:532) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:373) at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:241) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)

    Spring JIRA | 1 decade ago | Victor
    java.lang.IllegalStateException: Active Spring transaction synchronization or jtaTransactionManager on LocalSessionFactoryBean plus active JTA transaction required

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Active Spring transaction synchronization or jtaTransactionManager on LocalSessionFactoryBean plus active JTA transaction required

      at org.springframework.orm.hibernate.support.AbstractLobType.nullSafeSet()
    2. Hibernate
      AbstractLobType.nullSafeSet
      1. org.springframework.orm.hibernate.support.AbstractLobType.nullSafeSet(AbstractLobType.java:169)
      1 frame
    3. net.sf.hibernate
      SessionImpl.flush
      1. net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118)
      2. net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:393)
      3. net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:466)
      4. net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
      5. net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
      6. net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
      7. net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)
      8. net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
      8 frames
    4. Hibernate
      SessionFactoryUtils$JtaSessionSynchronization.beforeCompletion
      1. org.springframework.orm.hibernate.SessionFactoryUtils$SpringSessionSynchronization.beforeCommit(SessionFactoryUtils.java:655)
      2. org.springframework.orm.hibernate.SessionFactoryUtils$JtaSessionSynchronization.beforeCompletion(SessionFactoryUtils.java:740)
      2 frames
    5. com.ibm.ejs
      UserTransactionImpl.commit
      1. com.ibm.ejs.jts.jta.TransactionImpl.before_completion(TransactionImpl.java:966)
      2. com.ibm.ejs.jts.jts.CoordinatorImpl$Sync.beforePrepare(CoordinatorImpl.java:692)
      3. com.ibm.ejs.jts.tran.EventCallback.executeCallback(EventCallback.java:166)
      4. com.ibm.ejs.jts.tran.EventCallback.executeCallbackTree(EventCallback.java:132)
      5. com.ibm.ejs.jts.tran.EventPrepare.ExecuteBeforePrepareCallbacks(EventPrepare.java:297)
      6. com.ibm.ejs.jts.tran.EventPrepare.event_LocalPrepareWork(EventPrepare.java:277)
      7. com.ibm.ejs.jts.tran.EventPrepare.event_BecomeCoordinator(EventPrepare.java:960)
      8. com.ibm.ejs.jts.tran.EventControl.event_EndTopLevel(EventControl.java:295)
      9. com.ibm.ejs.jts.tran.TrecInterface.end(TrecInterface.java:88)
      10. com.ibm.ejs.jts.jts.TerminatorImpl.commit(TerminatorImpl.java:89)
      11. com.ibm.ejs.jts.jts.CurrentImpl.commit(CurrentImpl.java:200)
      12. com.ibm.ejs.jts.jts.CurrentSet.commit(CurrentSet.java:256)
      13. com.ibm.ejs.jts.jts.Current.commit(Current.java:71)
      14. com.ibm.ejs.jts.jta.UserTransactionImpl.commit(UserTransactionImpl.java:182)
      14 frames
    6. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:532)
      2. org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:373)
      3. org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:241)
      4. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66)
      4 frames
    7. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
      2 frames