Uploaded image for project: 'ActiveMQ'
  1. ActiveMQ
  2. AMQ-6160

JDBC XA: NullPointerException on rollback in PREPARED_STATE when trying to unset the XID

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 5.12.1, 5.13.0, 5.13.1
    • None
    • Broker, JDBC
    • None
    • Patch Available

    Description

      The messageId.getEntryLocator() gives null which leads to the NPE.

      The NPE seems to lead to a db connection leak in conjunction with Apache Commons DBCP. A workaround we applied is to configure the pool to remove this "abandoned" connections (see https://commons.apache.org/proper/commons-dbcp/configuration.html):

          <bean id="mysql-ds" class="..." destroy-method="close">
              ...
              <property name="removeAbandonedOnMaintenance" value="true"/>
              <property name="removeAbandonedOnBorrow" value="false"/>
              <property name="removeAbandonedTimeout" value="300"/>
              <property name="logAbandoned" value="true"/>
          </bean>
      

      Example stacktrace for the NPE:

      11:12:32.965 [messageListenerContainer-7] WARN  c.a.d.xa.XAResourceTransaction - XA resource 'atomikosFactorIn': rollback for XID '3137322E31362E3231352E34312E746D30303030363030303435:3137322E31362E3231352E34312E746D313136' raised -7: the XA resource has become unavailable
      javax.transaction.xa.XAException: java.lang.NullPointerException
              at org.apache.activemq.TransactionContext.toXAException(TransactionContext.java:735) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.TransactionContext.rollback(TransactionContext.java:497) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.datasource.xa.XAResourceTransaction.rollback(XAResourceTransaction.java:677) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.RollbackMessage.send(RollbackMessage.java:70) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:83) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:79) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.Propagator.submitPropagationMessage(Propagator.java:58) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.CoordinatorStateHandler.rollbackFromWithinCallback(CoordinatorStateHandler.java:709) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.ActiveStateHandler$4.doRollback(ActiveStateHandler.java:213) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.CoordinatorStateHandler.rollbackWithAfterCompletionNotification(CoordinatorStateHandler.java:837) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.ActiveStateHandler.rollbackWithAfterCompletionNotification(ActiveStateHandler.java:49) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.ActiveStateHandler.prepare(ActiveStateHandler.java:208) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.CoordinatorImp.prepare(CoordinatorImp.java:681) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.CoordinatorImp.terminate(CoordinatorImp.java:975) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.CompositeTerminatorImp.commit(CompositeTerminatorImp.java:82) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.imp.CompositeTransactionImp.commit(CompositeTransactionImp.java:336) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.jta.TransactionImp.commit(TransactionImp.java:190) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.jta.TransactionManagerImp.commit(TransactionManagerImp.java:436) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at com.atomikos.icatch.jta.UserTransactionImp.commit(UserTransactionImp.java:107) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1021) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:247) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1150) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1142) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1039) [messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at java.lang.Thread.run(Thread.java:745) [na:1.7.0_76]
      Caused by: javax.jms.JMSException: java.lang.NullPointerException
              at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1287) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.TransactionContext.syncSendPacketWithInterruptionHandling(TransactionContext.java:704) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.TransactionContext.rollback(TransactionContext.java:487) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              ... 25 common frames omitted
      Caused by: java.lang.NullPointerException: null
              at org.apache.activemq.store.jdbc.JdbcMemoryTransactionStore.rollback(JdbcMemoryTransactionStore.java:181) ~[na:na]
              at org.apache.activemq.transaction.XATransaction.rollback(XATransaction.java:146) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.broker.TransactionBroker.rollbackTransaction(TransactionBroker.java:257) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.broker.BrokerFilter.rollbackTransaction(BrokerFilter.java:148) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.broker.BrokerFilter.rollbackTransaction(BrokerFilter.java:148) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.broker.MutableBrokerFilter.rollbackTransaction(MutableBrokerFilter.java:153) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.broker.TransportConnection.processRollbackTransaction(TransportConnection.java:522) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.command.TransactionInfo.visit(TransactionInfo.java:104) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:339) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:188) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:125) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.transport.AbstractInactivityMonitor.onCommand(AbstractInactivityMonitor.java:300) ~[na:na]
              at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.transport.nio.NIOTransport.serviceRead(NIOTransport.java:156) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.transport.nio.NIOTransport$1.onSelect(NIOTransport.java:80) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.transport.nio.SelectorSelection.onSelect(SelectorSelection.java:97) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at org.apache.activemq.transport.nio.SelectorWorker$1.run(SelectorWorker.java:119) ~[messaging-test-tool-1.0-SNAPSHOT.2.jar:na]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_76]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_76]
              ... 1 common frames omitted
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jenshadlich Jens Hadlich
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m