Jiri Luzny wrote:
> They don't call the Transaction stuff directly.
> They
>   a) register a listener to TransactionManager to be notified about
> the events
>   b)  use a connection from a connection pool
> (org.jboss.jdbc.XADataSourceLoader) for commit/rollback/close...
> 
> So Toplink just calls connection.close() within afterCompletion and
> the rest is actually invoked by XAClientConnection.close() method.
> 
> Here there is the full stack trace that describes it better:
> 
> java.lang.RuntimeException: Unable to deregister with
> TransactionManager: java.lang.IllegalStateException:
> Already committed.
> 
>org.jboss.pool.jdbc.xa.XAConnectionFactory$2.closeConnection(XAConnectionFactory.java:110)
> 
>org.jboss.pool.jdbc.xa.XAConnectionFactory$2.connectionClosed(XAConnectionFactory.java:89)
> 
>org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl.clientConnectionClosed(XAConnectionImpl.java:134)
> org.jboss.pool.jdbc.xa.wrapper.XAClientConnection.close(XAClientConnection.java:250)
> 
>TOPLink.Private.DatabaseAccess.DatabaseAccessor.closeConnection(DatabaseAccessor.java:439)
> 
>TOPLink.Private.DatabaseAccess.DatabaseAccessor.afterJTSTransactionCommit(DatabaseAccessor.java:125)
> 
>TOPLink.Public.ThreeTier.ClientSession.afterCommitJTSTransaction(ClientSession.java:73)
> 
>TOPLink.Public.JTS.AbstractSynchronizationListener.afterCompletion(AbstractSynchronizationListener.ja
> va:73)
> org.jboss.tm.TxCapsule.doAfterCompletion(TxCapsule.java:1233)
> org.jboss.tm.TxCapsule.commit(TxCapsule.java:355)
> org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:76)
> ...

Ah, now I get it.

Looking back at the code, I see that I was not quite correct
about what I said about the existence of the transaction
during the afterCompletion callback. The transaction still
exists at this point, and has state STATUS_COMMITTED when
the transaction was committed. Still cannot register XA
resources in that state. Only after the afterCompletion
callbacks are done, the transaction seizes to exist.

In the jbosspool CVS module, in source file
org/jboss/pool/jdbc/xa/XAConnectionFactory.java there is a
check in line 101 if the transaction is non-existent.
However that is not really enough because states exist
where the transaction still exists, but resources can no
longer be delisted.

Line 101 should probably be changed from:
    if(tm.getStatus() != Status.STATUS_NO_TRANSACTION) {
to:
    if (tm.getStatus() == Status.STATUS_ACTIVE ||
        tm.getStatus() == Status.STATUS_MARKEDROLLBACK) {

I think that this change should fix your problem.

Please let me know if it does, and I'll do all the
testing we have to do before committing to CVS on
the stable branch.
Then, the fix will be in the next 2.4.x release.


Best Regards,

Ole Husgaard.

P.S: I'm not sure that is all that needs to be fixed here,
looks like the connection is not removed from the rms map
if the transaction is no longer active when the connection
is closed. No big memory leak, since these connections are
reused and then will drop the old XAResource from this map,
but...

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to