0 Replies Latest reply on Nov 12, 2007 4:36 PM by jansie

    Transaction Synchronization Issue

    jansie

      S/W used

      Jboss: 4.2.1
      DB: SQL Server 2005
      Spring : 2.0.2
      Hibernate : 3.2.1

      In our scenario we are having
      1)Bean A and Bean B
      2)Bean A invokes a method on Bean B whose transaction attribute is Requires_New
      3) In the invoked method of Bean B datasource lookup is done to get a new connection
      4) As soon as Bean A invokes the method on Bean B the below exception is thrown.

      [JtaTransactionManager] Suspending current transaction, creating new transaction with name [com.priya...sequence.interfaces.ICustomMySequenceOrganizer.getSequenceNextVal]
      [org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [org.springframework.orm.hibernate3.SessionHolder@1d16efc] for key [org.hibernate.impl.SessionFactoryImpl@895684] from thread [http-localhost%2F10.3.89.177-8080-1]

      [org.springframework.transaction.support.TransactionSynchronizationManager] Clearing transaction synchronization
      [STDERR] java.lang.IllegalStateException: Trying to change transaction TransactionImple < ac, BasicAction: a0359b1:4e3:4734f5c7:fc status: ActionStatus.RUNNING > in enlist!
      [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:525)
      [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.transactionStarted(TxConnectionManager.java:328)
      [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionManager.userTransactionStarted(CachedConnectionManager.java:360)
      [STDERR] at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.begin(ServerVMClientUserTransaction.java:127)
      [STDERR] at org.springframework.transaction.jta.JtaTransactionManager.doJtaBegin(JtaTransactionManager.java:724)
      [STDERR] at org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:681)
      [STDERR] at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:396)
      [STDERR] at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:329)
      [STDERR] at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262)
      [STDERR] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
      [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      [STDERR] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      [STDERR] at $Proxy89.getSequenceNextVal(Unknown Source)
      [ Show » ] Muthukumaran Madialagan - 12/Nov/07 02:43 PM In our scenario we are having 1)Bean A and Bean B 2)The transaction attribute of Bean A is requires and the Transaction Attribute of Bean B is Requires New. 3) Bean A calls Bean B by passing the datasource as an input parameter. 4)When Bean A calls Bean B the current transaction of Bean A is suspended and new transaction is created. Then TransactionSyncronizationManager clears the transaction synchronization. While trying to initialise a new transaction the below exception is thrown. [JtaTransactionManager] Suspending current transaction, creating new transaction with name [com.priya...sequence.interfaces.ICustomMySequenceOrganizer.getSequenceNextVal] [org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [org.springframework.orm.hibernate3.SessionHolder@1d16efc] for key [org.hibernate.impl.SessionFactoryImpl@895684] from thread [http-localhost%2F10.3.89.177-8080-1] [org.springframework.transaction.support.TransactionSynchronizationManager] Clearing transaction synchronization [STDERR] java.lang.IllegalStateException: Trying to change transaction TransactionImple < ac, BasicAction: a0359b1:4e3:4734f5c7:fc status: ActionStatus.RUNNING > in enlist! [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:525) [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.transactionStarted(TxConnectionManager.java:328) [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionManager.userTransactionStarted(CachedConnectionManager.java:360) [STDERR] at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.begin(ServerVMClientUserTransaction.java:127) [STDERR] at org.springframework.transaction.jta.JtaTransactionManager.doJtaBegin(JtaTransactionManager.java:724) [STDERR] at org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:681) [STDERR] at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:396) [STDERR] at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:329) [STDERR] at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262) [STDERR] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [STDERR] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) [STDERR] at $Proxy89.getSequenceNextVal(Unknown Source)