ManagedConnection.cleanup called before XAResource.end
I am the developer for a JCA 1.5 resource adapter named DTPRA. Note that DTPRA works with WebSphere Application Server, WebLogic Application Server and JBoss Application Server.
I have never tested DTPRA with the Sun App Server, so I downloaded Sun Java System Application Server Enterprise Edition 8.2 (build b25-fcs) to test DTPRA.
After overcoming a number of other issues, I encountered a problem which has me stalled at this point.
I tried a simple transaction request. At the end of the 揳ctive?phase of processing, the App Server called the ManagedConnection.cleanup method prior to calling to the XAResource.end method. When the XAResource.end method was called later, DTPRA threw the exception because the state was wrong (the managed connection was no longer involved in a transaction). Here is an excerpt from the DTPRA trace:
-
06/27/07 13:27:32.340 RA=dtpraTYPE=FINERTHD=0084e723-service-j2ee
DtpInteraction.execute: returning from execute a value oftrue
DtpConnection.destroyInteraction: Entering method
DtpConnection.close: Entering method close (for connectioncom.unisys.dtp.connector.DtpConnection@557c15)
DtpConnection.closeConnection: no interactions to close
DtpConnection.closeConnection: connection com.unisys.dtp.connector.DtpConnection@557c15 no longer active
DtpManagedConnection.fireConnectionClosedEvent: Firing Connection closed event; 1 listeners() registered
DtpManagedConnection.cleanup: Entering method
-
06/27/07 13:27:32.340 RA=dtpraTYPE=FINETHD=0084e723-service-j2ee
DtpManagedConnection.cleanup: Clean Up Request: 1 connection(s) active
-
06/27/07 13:27:32.340 RA=dtpraTYPE=FINERTHD=0084e723-service-j2ee
DtpManagedConnection.cleanup: ManagedConnection cleanup successful
DtpXAResource.end: xa_end called flags = TMSUCCESS (0x4000000)
-
06/27/07 13:27:32.340 RA=dtpraTYPE=FINEST THD=0084e723-service-j2ee
DtpResourceAdapter.createXid: txHelper is null...
-
06/27/07 13:27:32.340 RA=dtpraTYPE=SEVERE THD=0084e723-service-j2ee
DtpManagedConnection.transactionCompleted: Throwing exception.
javax.resource.spi.IllegalStateException: XA_END Received but ManagedConnection not currently participating in transaction, error code: NO_TRANS
at com.unisys.dtp.connector.DtpManagedConnection.transactionCompleted(DtpManagedConnection.java:1014)
at com.unisys.dtp.connector.DtpXAResource.end(DtpXAResource.java:160)
at com.sun.jts.jta.TransactionState.beforeCompletion(TransactionState.java:125)
at com.sun.jts.jta.SynchronizationImpl.before_completion(SynchronizationImpl.java:62)
at com.sun.jts.CosTransactions.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:120)
at com.sun.jts.CosTransactions.TopCoordinator.beforeCompletion(TopCoordinator.java:2491)
The Sun App Server behavior looks incorrect to me. I reviewed the JCA 1.5 spec (page 6-43 shows a nice diagram), and it looks like the App Server is supposed to call XAResource.end before the App Server calls ManagedConnection.cleanup. This is what DTPRA expects and gets with the other App Servers.

