Search in sources :

Example 61 with XAException

use of javax.transaction.xa.XAException in project voltdb by VoltDB.

the class JDBCXAResource method start.

public void start(Xid xid, int flags) throws XAException {
    // Comment out following debug statement before public release:
    System.err.println("STARTING NEW Xid: " + xid);
    if (state != XA_STATE_INITIAL && state != XA_STATE_DISPOSED) {
        throw new XAException("Invalid XAResource state");
    }
    if (xaDataSource == null) {
        throw new XAException("JDBCXAResource has not been associated with a XADataSource");
    }
    if (xid == null) {
        // >= XA_STATE_STARTED have a non-null xid.
        throw new XAException("Null Xid");
    }
    try {
        // real/phys.
        originalAutoCommitMode = connection.getAutoCommit();
        // real/phys.
        connection.setAutoCommit(false);
    } catch (SQLException se) {
        throw new XAException(se.getMessage());
    }
    this.xid = xid;
    state = XA_STATE_STARTED;
    xaDataSource.addResource(this.xid, this);
// N.b.  The DataSource does not have this XAResource in its list
// until right here.  We can't tell DataSource before our start()
// method, because we don't know our Xid before now.
}
Also used : XAException(javax.transaction.xa.XAException) SQLException(java.sql.SQLException)

Example 62 with XAException

use of javax.transaction.xa.XAException in project aries by apache.

the class NamedXAResourceImpl method checkOpen.

private void checkOpen() throws XAException {
    if (closed) {
        XAException xaException = new XAException("This instance of the resource named " + name + " is no longer available");
        xaException.errorCode = XAException.XAER_RMFAIL;
        throw xaException;
    }
}
Also used : XAException(javax.transaction.xa.XAException)

Example 63 with XAException

use of javax.transaction.xa.XAException in project geode by apache.

the class XAResourceAdaptor method testXAExceptionInCommit.

@Test
public void testXAExceptionInCommit() throws Exception {
    utx.begin();
    Thread thread = Thread.currentThread();
    Transaction txn = (Transaction) tm.getTransactionMap().get(thread);
    txn.registerSynchronization(new Synchronization() {

        public void beforeCompletion() {
        }

        public void afterCompletion(int status) {
            assertTrue(status == Status.STATUS_ROLLEDBACK);
        }
    });
    txn.enlistResource(new XAResourceAdaptor() {

        public void commit(Xid arg0, boolean arg1) throws XAException {
            throw new XAException(5);
        }

        public void rollback(Xid arg0) throws XAException {
            throw new XAException(6);
        }
    });
    try {
        utx.commit();
        fail("The commit should have thrown SystemException");
    } catch (SystemException expected) {
    // success
    }
    assertTrue(tm.getGlobalTransactionMap().isEmpty());
}
Also used : Xid(javax.transaction.xa.Xid) XAException(javax.transaction.xa.XAException) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 64 with XAException

use of javax.transaction.xa.XAException in project ignite by apache.

the class CacheJtaResource method throwException.

/**
     * @param msg Message.
     * @param cause Cause.
     * @throws XAException XA exception.
     */
private void throwException(String msg, Throwable cause) throws XAException {
    XAException ex = new XAException(msg);
    ex.initCause(cause);
    throw ex;
}
Also used : XAException(javax.transaction.xa.XAException)

Example 65 with XAException

use of javax.transaction.xa.XAException in project jackrabbit by apache.

the class XASessionImpl method prepare.

/**
     * {@inheritDoc}
     */
public int prepare(Xid xid) throws XAException {
    TransactionContext tx = txGlobal.get(xid);
    if (tx == null) {
        throw new XAException(XAException.XAER_NOTA);
    }
    tx.prepare();
    return XA_OK;
}
Also used : XAException(javax.transaction.xa.XAException) TransactionContext(org.apache.jackrabbit.data.core.TransactionContext)

Aggregations

XAException (javax.transaction.xa.XAException)68 IOException (java.io.IOException)20 Xid (javax.transaction.xa.Xid)19 SystemException (javax.transaction.SystemException)14 TransactionContext (com.hazelcast.transaction.TransactionContext)12 RollbackException (javax.transaction.RollbackException)8 XAResource (javax.transaction.xa.XAResource)8 HeuristicRollbackException (javax.transaction.HeuristicRollbackException)7 HeuristicMixedException (javax.transaction.HeuristicMixedException)6 Test (org.junit.Test)6 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)6 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 HashMap (java.util.HashMap)5 XaResource (org.neo4j.kernel.impl.transaction.xaframework.XaResource)4 ArrayList (java.util.ArrayList)3 InvalidRecordException (org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)3 NodeRecord (org.neo4j.kernel.impl.nioneo.store.NodeRecord)3 PropertyIndexRecord (org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord)3 PropertyRecord (org.neo4j.kernel.impl.nioneo.store.PropertyRecord)3