@Override public final XAException rollbackOnlyFailed(final int errorCode, final SystemException e) { final XAException result = new XAException(String.format(getLoggingLocale(), rollbackOnlyFailed$str())); result.initCause(e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); result.errorCode = errorCode; return result; } private static final String notActiveXA = "WFTXN0067: Transaction is not active";
/** * Converts a JMSException from the server to an XAException. if the * JMSException contained a linked XAException that is returned instead. * * @param e JMSException to convert * @return XAException wrapping original exception or its message */ private XAException toXAException(JMSException e) { if (e.getCause() != null && e.getCause() instanceof XAException) { XAException original = (XAException)e.getCause(); XAException xae = new XAException(original.getMessage()); xae.errorCode = original.errorCode; if (xae.errorCode == XA_OK) { // detail not unmarshalled see: org.apache.activemq.openwire.v1.BaseDataStreamMarshaller.createThrowable xae.errorCode = parseFromMessageOr(original.getMessage(), XAException.XAER_RMERR); } xae.initCause(original); return xae; } XAException xae = new XAException(e.getMessage()); xae.errorCode = XAException.XAER_RMFAIL; xae.initCause(e); return xae; }
/** * @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; }
@Override public final XAException duplicateTransaction(final int errorCode, final URI uri, final Xid xid) { final XAException result = new XAException(String.format(getLoggingLocale(), duplicateTransaction$str(), uri, xid)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); result.errorCode = errorCode; return result; } private static final String failedToReceiveXA = "WFTXN0025: Failed to receive protocol message from remote peer";
public void forget (Xid xid) throws XAException { try { SubordinateTransaction tx = SubordinationManager .getTransactionImporter().getImportedTransaction(xid); if (tx == null) throw new XAException(XAException.XAER_INVAL); tx.doForget(); } catch (Exception ex) { XAException xaException = new XAException(XAException.XAER_RMERR); xaException.initCause(ex); throw xaException; } finally { SubordinationManager.getTransactionImporter() .removeImportedTransaction(xid); } }
xaResource.commit(xid, true) ; return TwoPhaseOutcome.FINISH_OK ; jtaLogger.logger.trace("XAOnePhaseResource.commit(" + xid + ") " + xae.getMessage()); jtaLogger.i18NLogger.warn_resources_arjunacore_opcerror(XAHelper.xidToString(xid), xaResource.toString(), XAHelper.printXAErrorCode(xae), xae); String xidString = xid == null ? "< >" : XAHelper.xidToString(xid); String resourceString = xaResource == null ? "null XA resource" : xaResource.toString(); jtaLogger.i18NLogger.warn_resources_arjunacore_commitxaerror(xidString, resourceString, "-", ex); xaResource.forget(xid);
throw new XAException(XAException.XAER_INVAL); tx.doOnePhaseCommit(); else if (!tx.doCommit()) { throw new XAException(XAException.XAER_RMFAIL); throw new XAException(XAException.XA_RETRY); SubordinationManager.getTransactionImporter() .removeImportedTransaction(xid); XAException xaException = new XAException(XAException.XA_RBROLLBACK); xaException.initCause(e); throw xaException; XAException xaException = new XAException(XAException.XA_HEURCOM); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XA_HEURRB); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XA_HEURMIX); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XAER_NOTA); xaException.initCause(ex);
.getTransactionImporter().getImportedTransaction(xid); throw new XAException(XAException.XAER_INVAL); if (tx.activated()) tx.doRollback(); throw new XAException(XAException.XA_RETRY); XAException xaException = new XAException(XAException.XA_HEURRB); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XA_HEURCOM); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XA_HEURMIX); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XAER_NOTA); xaException.initCause(ex); throw xaException; throw new XAException(XAException.XAER_RMERR);
.getTransactionImporter().getImportedTransaction(xid); throw new XAException(XAException.XAER_INVAL); if (tx.baseXid() != null) throw new XAException(XAException.XA_RETRY); XAException xaException = new XAException(XAException.XA_HEURCOM); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XA_HEURRB); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XA_HEURMIX); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XAER_NOTA); xaException.initCause(ex); throw xaException; XAException xaException = new XAException(XAException.XAER_RMERR); xaException.initCause(ex); throw xaException;
@Test public void testFailOnCommitOnePhase () throws Exception { final Xid xid = new XidImple(new Uid()); final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid); final TestXAResource xaResource = new TestXAResource(); // provoke commit into failing with TwoPhaseOutcome.FINISH_ERROR // warning: this is sensitive to the impl exception handling in // XAResourceRecord.topLevelCommit xaResource.setCommitException(new XAException(XAException.XA_HEURRB)); // should cause an exception! t.enlistResource(xaResource); final XATerminator xaTerminator = SubordinationManager.getXATerminator(); try { xaTerminator.commit(xid, true); } catch (final XAException ex) { // success! return; } assertTrue("commit should throw an exception and not get to here", false); }
@Override public void start(Xid xid, int flags) throws XAException { try { xaresource.start(xid, flags); if (logger.isLogEnabled()) { logger.log("XA start on " + systemToString(xid)); } } catch (NuxeoException e) { throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } catch (XAException e) { logger.error("XA start error on " + systemToString(xid), e); throw e; } }
@Override public Xid[] recover(int i) throws XAException { if (i == TMENDRSCAN) { try { xaConnection.close(); return null; } catch (SQLException e) { throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } } else { return xaResource.recover(i); } }
/** * {@inheritDoc} */ @Override public void commit() throws ResourceException { try { resource.end(xid, XAResource.TMSUCCESS); resource.commit(xid, true); } catch (XAException e) { throw new ResourceException(e.getMessage()); } }
/** * {@inheritDoc} */ @Override public void rollback() throws ResourceException { try { resource.end(xid, XAResource.TMFAIL); resource.rollback(xid); } catch (XAException e) { throw new ResourceException(e.getMessage()); } }
.getTransactionImporter().getImportedTransaction(xid); throw new XAException(XAException.XAER_INVAL); switch (tx.doPrepare()) SubordinationManager.getTransactionImporter() .removeImportedTransaction(xid); SubordinationManager.getTransactionImporter() .removeImportedTransaction(xid); throw new XAException(XAException.XA_RBROLLBACK); case TwoPhaseOutcome.PREPARE_OK: return XAResource.XA_OK; case TwoPhaseOutcome.INVALID_TRANSACTION: throw new XAException(XAException.XAER_NOTA); default: throw new XAException(XAException.XA_RBOTHER);
int result = subordinateTransaction.doPrepare(); switch (result) { case TwoPhaseOutcome.PREPARE_READONLY: SubordinationManager.getTransactionImporter().removeImportedTransaction(this.xidTransactionID.getXid()); return XAResource.XA_RDONLY; int xaExceptionCode = XAException.XA_RBROLLBACK; try { subordinateTransaction.doRollback(); } catch (HeuristicCommitException e) { initCause = e; SubordinationManager.getTransactionImporter().removeImportedTransaction(this.xidTransactionID.getXid()); final XAException xaException = new XAException(xaExceptionCode); if (initCause != null) { xaException.initCause(initCause); throw new XAException(XAException.XAER_NOTA); throw new XAException(XAException.XA_RBOTHER);
/** * {@inheritDoc} */ @Override public void begin() throws ResourceException { try { this.xid = new XidImpl(intToByteArray(globalCounter.getAndIncrement())); resource.start(xid, XAResource.TMNOFLAGS); } catch (XAException e) { throw new ResourceException(e.getMessage()); } }
private void checkOpen() throws XAException { if (physicalConn == null) { throw new XAException(XAException.XAER_RMERR); } }
trans = xares.recover(XAResource.TMSTARTRSCAN); new Object[] { _logName + ".xaRecovery ", e, XAHelper.printXAErrorCode(e) }); xares.recover(XAResource.TMENDRSCAN); new Object[] { XAHelper .xidToString((Xid) xids[j]) }); xares.rollback((Xid) xids[j]); new Object[] { XAHelper .xidToString((Xid) xids[j]) }); e1.printStackTrace();
public void commit(Xid xid, boolean flag) throws XAException{ try{ m_xacon.getXAResource().commit(xid, flag); }catch(ResourceException e){ //a bad xa connection given... throw new XAException(sm.getString("transaction.sybase_xa_wrapper_connection_failed",e)); // throw new XAException("sybase XA resource wrapper :Could not connect : sqlexception was "+e); } } public void rollback(Xid xid) throws XAException{