4 Replies Latest reply on Jun 6, 2008 6:32 AM by Michael Musgrove

    Transaction is not active!!

    Ramkumar Krishnan Newbie

      Hi,
      I am invoking a batch job which runs for half a minute and throws the following exception. This problem happens only when i use 2pc.

      I am using the following
      Jboss 4.0.5
      MySql 5.0.5 (Driver)
      Mysql 5.1.23 (Mysql database)
      Spring 2.5.4
      Hibernate 3.2.3

      Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.jboss.util.NestedSQLException: Transaction is not active:

      tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=Ramkumar-TI6964/71, BranchQual=, localId=71]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=Ramkumar-TI6964/71, BranchQual=, localId=71])
      at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)
      at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:577)
      at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:792)
      at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:850)
      at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:854)
      at org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.updateStepExecution(JdbcStepExecutionDao.java:324)
      at org.springframework.batch.core.repository.support.SimpleJobRepository.saveOrUpdate(SimpleJobRepository.java:239)
      at org.springframework.batch.core.repository.support.SimpleJobRepository.saveOrUpdateExecutionContext(SimpleJobRepository.java:248)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      at $Proxy62.saveOrUpdateExecutionContext(Unknown Source)
      at org.springframework.batch.core.step.item.ItemOrientedStep$1.doInIteration(ItemOrientedStep.java:260)
      ... 14 more
      Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=Ramkumar-TI6964/71, BranchQual=, localId=71]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=Ramkumar-TI6964/71, BranchQual=, localId=71])
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)
      at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
      at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
      ... 35 more
      Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=Ramkumar-TI6964/71, BranchQual=, localId=71]
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:290)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:396)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)



      And this is one of the XA sources defined in our mysql-ds.xml
      <xa-datasource>
      
       <jndi-name>DarkDS</jndi-name>
       <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
       <xa-datasource-property name="Url">jdbc:mysql://172.16.160.126/dev</xa-datasource-property>
       <xa-datasource-property name="User">om_user</xa-datasource-property>
       <xa-datasource-property name="Password">deer12#$</xa-datasource-property>
       <xa-resource-timeout>300</xa-resource-timeout>
       <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
       <track-connection-by-tx>true</track-connection-by-tx>
       <no-tx-separate-pools/>
       <isSameRM-override-value> false </isSameRM-override-value>
       <connection-property name="useOldAliasMetadataBehavior">true</connection-property>
       <password>chicago12#$</password>-->
       <new-connection-sql>select 1 from dual</new-connection-sql>
       <check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
       <background-validation>true</background-validation>
      
       <min-pool-size>30</min-pool-size>
      
       <max-pool-size>30</max-pool-size>
      
       <prepared-statement-cache-size>500</prepared-statement-cache-size>
      
       <idle-timeout-minutes>5</idle-timeout-minutes>
      
       <exception-sorter-class-name>
       com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter
       </exception-sorter-class-name>
       <valid-connection-checker-class-name>
       com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker
       </valid-connection-checker-class-name>
       </xa-datasource>


      Anyone faced this issue before? Am i missing something here?

      regards,
      Ramkumar