+

Search Tips | Advanced Search

J2CA0027E messages containing the error The method 'xa_end' has failed with errorCode '100'

J2CA0027E messages appear in the WebSphere Application Server SystemOut.log containing the error The method 'xa_end' has failed with errorCode '100'.


Introduction

The following errors appear in the WebSphere Application Server SystemOut.log file when applications using the WebSphere Application Server IBM MQ messaging provider try to commit a transaction:

J2CA0027E: An exception occurred while invoking end on an XA Resource Adapter from DataSource JMS_Connection_Factory, within transaction ID Transaction_Identifier: javax.transaction.xa.XAException: The method 'xa_end' has failed with errorCode '100'.
J2CA0027E: An exception occurred while invoking rollback on an XA Resource Adapter from DataSource JMS_Connection_Factory, within transaction ID Transaction_Identifier: javax.transaction.xa.XAException: The method 'xa_rollback' has failed with errorCode '-7'.


Cause

The cause of these errors can be the result of a IBM MQ messaging provider JMS connection being closed off by WebSphere Application Server because the aged timeout for the connection has expired.

JMS connections are created from a JMS connection factory. There is a connection pool associated with each connection factory, which is divided into two parts - the active pool and the free pool.

When an application closes off a JMS connection that it has been using, that connection is moved into the free pool of the connection pool for the connection factory unless the aged timeout for that connection has elapsed, in which case the connection is destroyed. If the JMS connection is still involved in an active transaction when it is destroyed, the application server flows an xa_end() to IBM MQ, indicating that all of the transactional work on that connection has completed.

This causes issues if the JMS connection had been created inside a transactional message-driven bean that was using either an activation specification or a listener port to monitor a JMS Destination on a IBM MQ queue manager.

In this situation, there is a single transaction that is using two connections to IBM MQ:

  • A connection which is used to get a message from IBM MQ and deliver it to the message-driven bean instance for processing.
  • A connection that is created within the message-driven bean's onMessage() method.

If the second connection is closed by the message-driven bean, and then destroyed as a result of the aged timeout expiring, then an xa_end() is flown to IBM MQ indicating that all of the transactional work has completed.

When the message-driven bean application finishes processing the message it has been given, the application server needs to complete the transaction. It does this by flowing xa_end() to all of the resources that were involved in the transaction, including IBM MQ.

However, IBM MQ has already received an xa_end() for this particular transaction, and so returns an XA_RBROLLBACK (100) error back to WebSphere Application Server, indicating that the transaction has ended and all of the work IBM MQ has been rolled back. This causes the application server to report the following error:
J2CA0027E: An exception occurred while invoking end on an XA Resource Adapter from DataSource JMS_Connection_Factory, within transaction ID Transaction_Identifier: javax.transaction.xa.XAException: The method 'xa_end' has failed with errorCode '100'.
and then roll back the entire transaction by flowing xa_rollback() to all of the resources enlisted in the transaction. When the application server flows xa_rollback() to IBM MQ, the following error occurs:
J2CA0027E: An exception occurred while invoking rollback on an XA Resource Adapter from DataSource JMS_Connection_Factory, within transaction ID Transaction_Identifier: javax.transaction.xa.XAException: The method 'xa_rollback' has failed with errorCode '-7'.  


Environment

Message-driven bean applications that use activation specifications or listener ports to monitor JMS Destinations hosted on a IBM MQ queue manager, and then create a new connection to IBM MQ using a JMS connection factory from within its onMessage() method, can be affected by this issue.


Resolving the problem

To resolve this issue, ensure that the JMS connection factory being used by the application has the connection pool property aged timeout set to zero. This will prevent JMS Connections being closed when they are returned to the free pool, and so ensures that any outstanding transactional work can be completed.

Parent topic: Java and JMS troubleshooting

Last updated: 2020-10-04