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.
}
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;
}
}
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());
}
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;
}
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;
}
Aggregations