Atomikos Forum

javax.jms.TransactionInProgressException: Cannot rollback()

Hi All,

i am facing an issue , when testing XA transaction using active MQ , Spring and Atomikos , that every time my message receiver connected to the active MQ broker , it give me in continuous way an exception :

DEBUG - atomikos                      - JMS: driver complains while enforcing XA mode - ignore if no later errors:
javax.jms.TransactionInProgressException: Cannot rollback() inside an XASession
    at org.apache.activemq.ActiveMQXASession.rollback(ActiveMQXASession.java:76)
    at com.atomikos.jms.AtomikosJmsConnectionProxy.forceConnectionIntoXaMode(AtomikosJmsConnectionProxy.java:70)
    at com.atomikos.jms.AtomikosJmsConnectionProxy.invoke(AtomikosJmsConnectionProxy.java:161)
    at $Proxy6.createSession(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.jms.connection.SingleConnectionFactory$SharedConnectionInvocationHandler.invoke(SingleConnectionFactory.java:550)
    at $Proxy7.createSession(Unknown Source)
    at org.springframework.jms.support.JmsAccessor.createSession(JmsAccessor.java:196)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.access$1(AbstractPollingMessageListenerContainer.java:1)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer$MessageListenerContainerResourceFactory.createSession(AbstractPollingMessageListenerContainer.java:532)
    at org.springframework.jms.connection.ConnectionFactoryUtils.doGetTransactionalSession(ConnectionFactoryUtils.java:300)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:289)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:244)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1071)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1063)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:960)
    at java.lang.Thread.run(Unknown Source)



and my transaction configuration :

    <!-- Construct Atomikos UserTransactionManager, needed to configure Spring -->
    <bean id="AtomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close">
        <!--  when close is called, should we force transactions to terminate or not? -->
        <property name="forceShutdown" value="true" />
    </bean>

    <!-- Also use Atomikos UserTransactionImp, needed to configure Spring  -->
    <bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
        <property name="transactionTimeout" value="300" />
    </bean>

    <!-- Configure the Spring framework to use JTA transactions from Atomikos -->
    <bean id="JtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManager" ref="AtomikosTransactionManager" />
        <property name="userTransaction" ref="AtomikosUserTransaction" />
    </bean>






and Spring configuration  :

 <bean id="amq.connectionFactory"
            class="org.apache.activemq.ActiveMQXAConnectionFactory">
        <property name="brokerURL"
                value="tcp://localhost:61616" />
      <!--    <property name="useDedicatedTaskRunner"
                value="false" /> -->
        <property name="redeliveryPolicy" ref="redeliveryPolicy"/>
    </bean>
    
     <bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
        <property name="maximumRedeliveries" value="2"/>
        <property name="initialRedeliveryDelay" value="500"/>
        <property name="backOffMultiplier" value="2"/>
        <property name="useExponentialBackOff" value="true"/>
       
    </bean>
        

    <!-- queue -->
    <bean id="Queue" class="org.apache.activemq.command.ActiveMQQueue">
        <property name="physicalName" value="testQueue" />
    </bean>
    
    
    <!-- Configure the JMS connector; call init to register for recovery! -->
    <bean id="RealConnectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean " init-method="init">
        <property name="uniqueResourceName" value="amq1" />
        <property name="xaConnectionFactory" ref="amq.connectionFactory" />
        <property name="maxPoolSize" value="5" />
    </bean>



    <bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory" >
        <property name="targetConnectionFactory" ref="RealConnectionFactory" />
        <property name="exceptionListener" ref="jmsExceptionListener" />
    
    </bean>




          <!-- create real business object, this is your own implementation -->
    <bean id="mailRecieverImpl" class="com.ifs.mail.reciever.MailRecieverImpl">
        <property name="mailServiceImpl" ref="mailServiceImpl" />
    </bean>
   
   
   
    <!-- a kind of message listener pool that will listen to messages posted to 'requestQueue'
        with 3 threads, each one consuming a connection from bean 'ConnectionFactory' -->
    <bean id="MessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="transactionManager" ref="JtaTransactionManager" />
        <property name="connectionFactory" ref="connectionFactory" />
        <property name="messageListener" ref="mailRecieverImpl" />
        <property name="destinationName" value="testQueue" />
        <property name="concurrentConsumers" value="1" />
        <property name="receiveTimeout" value="3000" />
        <property name="sessionTransacted" value="true" />
        <property name="recoveryInterval" value="6000" />
        <property name="cacheLevel" value="0"/>
      <!--  <property name="cacheLevelName" value="CACHE_CONSUMER"/>
        <property name="autoStartup" value="true" /> -->
    </bean>
 
i do not why this issue happen , and how i can fix that type of exception ?

Thanks a lot
mahmoud romeh Send private email
Sunday, April 08, 2012
 
 
More info about the exception log :

DEBUG - JtaTransactionManager          - Creating new transaction with name [MessageListenerContainer]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
DEBUG - atomikos                      - getCompositeTransaction() returning NULL!
DEBUG - atomikos                      - Coordinator com.atomikos.spring.jms.tm0000100046 entering state: ACTIVE
DEBUG - atomikos                      - (1.5) executing task: com.atomikos.timing.PooledAlarmTimer@15983b7
DEBUG - atomikos                      - ThreadFactory: creating new thread: Atomikos:1
DEBUG - atomikos                      - Creating composite transaction: com.atomikos.spring.jms.tm0000100046
INFO  - atomikos                      - createCompositeTransaction ( 300000 ): created new ROOT transaction with id com.atomikos.spring.jms.tm0000100046
INFO  - atomikos                      - AtomikosConnectionFactoryBean 'amq1': createConnection()...
INFO  - atomikos                      - AtomikosConnectionFactoryBean 'amq1': init...
DEBUG - atomikos                      - atomikos connection pool 'amq1': current size: 1/1
DEBUG - atomikos                      - atomikos pooled connection for resource amq1: updating last time acquired
INFO  - atomikos                      - atomikos connection proxy for resource amq1: calling toString on JMS driver...
DEBUG - atomikos                      - atomikos connection proxy for resource amq1: toString returning ActiveMQConnection {id=ID:IBM-NNHR6SQFLVL-65469-1333899279654-0:2,clientId=null,started=false}
DEBUG - atomikos                      - atomikos pooled connection for resource amq1: returning proxy ActiveMQConnection {id=ID:IBM-NNHR6SQFLVL-65469-1333899279654-0:2,clientId=null,started=false}
DEBUG - atomikos                      - atomikos connection pool 'amq1': got connection from pool, new size: 0/1
INFO  - atomikos                      - atomikos connection proxy for resource amq1: calling toString on JMS driver...
DEBUG - atomikos                      - atomikos connection proxy for resource amq1: toString returning ActiveMQConnection {id=ID:IBM-NNHR6SQFLVL-65469-1333899279654-0:2,clientId=null,started=false}
DEBUG - atomikos                      - AtomikosConnectionFactoryBean 'amq1': createConnection() returning ActiveMQConnection {id=ID:IBM-NNHR6SQFLVL-65469-1333899279654-0:2,clientId=null,started=false}
INFO  - atomikos                      - atomikos connection proxy for resource amq1: calling setExceptionListener on JMS driver...
DEBUG - atomikos                      - atomikos connection proxy for resource amq1: setExceptionListener returning null
INFO  - atomikos                      - atomikos connection proxy for resource amq1: calling toString on JMS driver...
DEBUG - atomikos                      - atomikos connection proxy for resource amq1: toString returning ActiveMQConnection {id=ID:IBM-NNHR6SQFLVL-65469-1333899279654-0:2,clientId=null,started=false}
INFO  - SingleConnectionFactory        - Established shared JMS Connection: ActiveMQConnection {id=ID:IBM-NNHR6SQFLVL-65469-1333899279654-0:2,clientId=null,started=false}
DEBUG - atomikos                      - getCompositeTransaction()  returning instance with id com.atomikos.spring.jms.tm0000100046
INFO  - atomikos                      - atomikos connection proxy for resource amq1: creating XA-capable session...
DEBUG - atomikos                      - JMS: driver complains while enforcing XA mode - ignore if no later errors:
javax.jms.TransactionInProgressException: Cannot rollback() inside an XASession
    at org.apache.activemq.ActiveMQXASession.rollback(ActiveMQXASession.java:76)
    at com.atomikos.jms.AtomikosJmsConnectionProxy.forceConnectionIntoXaMode(AtomikosJmsConnectionProxy.java:70)
    at com.atomikos.jms.AtomikosJmsConnectionProxy.invoke(AtomikosJmsConnectionProxy.java:161)
    at $Proxy6.createSession(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.jms.connection.SingleConnectionFactory$SharedConnectionInvocationHandler.invoke(SingleConnectionFactory.java:550)
    at $Proxy7.createSession(Unknown Source)
    at org.springframework.jms.support.JmsAccessor.createSession(JmsAccessor.java:196)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.access$1(AbstractPollingMessageListenerContainer.java:1)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer$MessageListenerContainerResourceFactory.createSession(AbstractPollingMessageListenerContainer.java:532)
    at org.springframework.jms.connection.ConnectionFactoryUtils.doGetTransactionalSession(ConnectionFactoryUtils.java:300)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:289)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:244)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1071)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1063)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:960)
    at java.lang.Thread.run(Unknown Source)
mahmoud romeh Send private email
Sunday, April 08, 2012
 
 
Like the message does say:

DEBUG - atomikos                      - JMS: driver complains while enforcing XA mode - ignore if no later errors:


Ignore it, if you do not see any errors later - do you see any errors later on? Please post them if so.
Torsten Krah Send private email
Wednesday, April 11, 2012
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics