I am trying to use enhydra's connection pool/XA support for our
project.  It's a ServiceMix-based project, so we're using Aries'
"wrapper" around Geronimo's transaction manager.  Anyway, what I'm
seeing is that their XA code seems to be trying to re-enlist the same
connection.  Unfortunately, they re-use the same XAResource instance,
so I run into this bit of code causing me an error:

if (xaRes == manager.getCommitter()) {
  throw new IllegalStateException("xaRes " + xaRes + " is a committer
but is not active or suspended");
}

Their connection code looks like this:


public class StandardXAConnection
        extends StandardPooledConnection
        implements XAConnection, XAResource, Referenceable, Runnable {

...

        /**
         * We are required to maintain a 1-1 mapping between an XAConnection
         * and its corresponding XAResource. We achieve this by implementing
         * both interfaces in the same class.
         */
        public XAResource getXAResource() {
                return this;
        }
}

What I'm trying to understand is if they're attempting to do something
silly here or if I have something mis-configured.  We're using OpenJPA
and when it goes to close the connection (after it uses it for a
query), enhydra delists it from the current transaction.  Inside their
DataSource's "connectionClosed" method:

if ((tx != null) && (((StandardXAConnection)
xac).connectionHandle.isReallyUsed)) {
  try {
        tx.delistResource(xac.getXAResource(), XAResource.TMSUCCESS);
        // delist the xaResource
        log.debug(
                "StandardXAPoolDataSource:connectionClosed the resourse is 
delisted");
        } catch (Exception e) {
                log.error(
                "StandardXAPoolDataSource:connectionClosed Exception in 
connectionClosed:"
                + e);
        }
}

Does this all make sense?  Is there something I need to configure to
allow re-enlistment of resources or are they just doing something
bone-headed here?

Reply via email to