Java Code Examples for javax.transaction.xa.XAException#XA_HEURHAZ

The following examples show how to use javax.transaction.xa.XAException#XA_HEURHAZ . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XATestUtil.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Return a string for the error code of the XAException.
*/
public static String errorCode(XAException e)
{
    String error;
    switch(e.errorCode)
    {
    case XAException.XA_HEURCOM : error = "XA_HEURCOM "; break;
    case XAException.XA_HEURHAZ : error = "XA_HEURHAZ"; break;
    case XAException.XA_HEURMIX : error = "XA_HEURMIX"; break;
    case XAException.XA_HEURRB : error = "XA_HEURRB "; break;
    case XAException.XA_NOMIGRATE : error = "XA_NOMIGRATE "; break;
    case XAException.XA_RBCOMMFAIL : error = "XA_RBCOMMFAIL "; break;
    case XAException.XA_RBDEADLOCK : error = "XA_RBDEADLOCK "; break;
    case XAException.XA_RBINTEGRITY : error = "XA_RBINTEGRITY "; break;
    case XAException.XA_RBOTHER : error = "XA_RBOTHER "; break;
    case XAException.XA_RBPROTO : error = "XA_RBPROTO "; break;
    case XAException.XA_RBROLLBACK : error = "XA_RBROLLBACK "; break;
    case XAException.XA_RBTIMEOUT : error = "XA_RBTIMEOUT "; break;
    case XAException.XA_RBTRANSIENT : error = "XA_RBTRANSIENT "; break;
    case XAException.XA_RDONLY : error = "XA_RDONLY "; break;
    case XAException.XA_RETRY : error = "XA_RETRY "; break;
    case XAException.XAER_ASYNC : error = "XAER_ASYNC "; break;
    case XAException.XAER_DUPID : error = "XAER_DUPID "; break;
    case XAException.XAER_INVAL : error = "XAER_INVAL "; break;
    case XAException.XAER_NOTA : error = "XAER_NOTA "; break;
    case XAException.XAER_OUTSIDE : error = "XAER_OUTSIDE "; break;
    case XAException.XAER_PROTO : error = "XAER_PROTO "; break;
    case XAException.XAER_RMERR : error = "XAER_RMERR "; break;
    case XAException.XAER_RMFAIL : error = "XAER_RMFAIL "; break;
    default: error = Integer.toString(e.errorCode); break;
    }        
    return error;
}
 
Example 2
Source File: XATestUtil.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Return a string for the error code of the XAException.
*/
public static String errorCode(XAException e)
{
    String error;
    switch(e.errorCode)
    {
    case XAException.XA_HEURCOM : error = "XA_HEURCOM "; break;
    case XAException.XA_HEURHAZ : error = "XA_HEURHAZ"; break;
    case XAException.XA_HEURMIX : error = "XA_HEURMIX"; break;
    case XAException.XA_HEURRB : error = "XA_HEURRB "; break;
    case XAException.XA_NOMIGRATE : error = "XA_NOMIGRATE "; break;
    case XAException.XA_RBCOMMFAIL : error = "XA_RBCOMMFAIL "; break;
    case XAException.XA_RBDEADLOCK : error = "XA_RBDEADLOCK "; break;
    case XAException.XA_RBINTEGRITY : error = "XA_RBINTEGRITY "; break;
    case XAException.XA_RBOTHER : error = "XA_RBOTHER "; break;
    case XAException.XA_RBPROTO : error = "XA_RBPROTO "; break;
    case XAException.XA_RBROLLBACK : error = "XA_RBROLLBACK "; break;
    case XAException.XA_RBTIMEOUT : error = "XA_RBTIMEOUT "; break;
    case XAException.XA_RBTRANSIENT : error = "XA_RBTRANSIENT "; break;
    case XAException.XA_RDONLY : error = "XA_RDONLY "; break;
    case XAException.XA_RETRY : error = "XA_RETRY "; break;
    case XAException.XAER_ASYNC : error = "XAER_ASYNC "; break;
    case XAException.XAER_DUPID : error = "XAER_DUPID "; break;
    case XAException.XAER_INVAL : error = "XAER_INVAL "; break;
    case XAException.XAER_NOTA : error = "XAER_NOTA "; break;
    case XAException.XAER_OUTSIDE : error = "XAER_OUTSIDE "; break;
    case XAException.XAER_PROTO : error = "XAER_PROTO "; break;
    case XAException.XAER_RMERR : error = "XAER_RMERR "; break;
    case XAException.XAER_RMFAIL : error = "XAER_RMFAIL "; break;
    default: error = Integer.toString(e.errorCode); break;
    }        
    return error;
}
 
Example 3
Source File: XATerminatorImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void invokeOnePhaseCommit(XAResourceArchive archive) throws XAException {
	try {
		archive.commit(archive.getXid(), true);
	} catch (XAException xaex) {
		switch (xaex.errorCode) {
		case XAException.XA_HEURCOM:
		case XAException.XA_HEURHAZ:
		case XAException.XA_HEURMIX:
		case XAException.XA_HEURRB:
			logger.warn("An error occurred in one phase commit: {}, transaction has been completed!",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			throw xaex;
		case XAException.XAER_RMFAIL:
			logger.warn("An error occurred in one phase commit: {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			throw xaex;
		case XAException.XAER_NOTA:
		case XAException.XAER_INVAL:
		case XAException.XAER_PROTO:
			logger.warn("An error occurred in one phase commit: {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			throw new XAException(XAException.XAER_RMERR);
		case XAException.XAER_RMERR:
		case XAException.XA_RBCOMMFAIL:
		case XAException.XA_RBDEADLOCK:
		case XAException.XA_RBINTEGRITY:
		case XAException.XA_RBOTHER:
		case XAException.XA_RBPROTO:
		case XAException.XA_RBROLLBACK:
		case XAException.XA_RBTIMEOUT:
		case XAException.XA_RBTRANSIENT:
		default:
			logger.warn("An error occurred in one phase commit: {}, transaction has been rolled back!",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			throw new XAException(XAException.XA_HEURRB);
		}
	}
}
 
Example 4
Source File: XATestUtil.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Return a string for the error code of the XAException.
*/
public static String errorCode(XAException e)
{
    String error;
    switch(e.errorCode)
    {
    case XAException.XA_HEURCOM : error = "XA_HEURCOM "; break;
    case XAException.XA_HEURHAZ : error = "XA_HEURHAZ"; break;
    case XAException.XA_HEURMIX : error = "XA_HEURMIX"; break;
    case XAException.XA_HEURRB : error = "XA_HEURRB "; break;
    case XAException.XA_NOMIGRATE : error = "XA_NOMIGRATE "; break;
    case XAException.XA_RBCOMMFAIL : error = "XA_RBCOMMFAIL "; break;
    case XAException.XA_RBDEADLOCK : error = "XA_RBDEADLOCK "; break;
    case XAException.XA_RBINTEGRITY : error = "XA_RBINTEGRITY "; break;
    case XAException.XA_RBOTHER : error = "XA_RBOTHER "; break;
    case XAException.XA_RBPROTO : error = "XA_RBPROTO "; break;
    case XAException.XA_RBROLLBACK : error = "XA_RBROLLBACK "; break;
    case XAException.XA_RBTIMEOUT : error = "XA_RBTIMEOUT "; break;
    case XAException.XA_RBTRANSIENT : error = "XA_RBTRANSIENT "; break;
    case XAException.XA_RDONLY : error = "XA_RDONLY "; break;
    case XAException.XA_RETRY : error = "XA_RETRY "; break;
    case XAException.XAER_ASYNC : error = "XAER_ASYNC "; break;
    case XAException.XAER_DUPID : error = "XAER_DUPID "; break;
    case XAException.XAER_INVAL : error = "XAER_INVAL "; break;
    case XAException.XAER_NOTA : error = "XAER_NOTA "; break;
    case XAException.XAER_OUTSIDE : error = "XAER_OUTSIDE "; break;
    case XAException.XAER_PROTO : error = "XAER_PROTO "; break;
    case XAException.XAER_RMERR : error = "XAER_RMERR "; break;
    case XAException.XAER_RMFAIL : error = "XAER_RMFAIL "; break;
    default: error = Integer.toString(e.errorCode); break;
    }        
    return error;
}
 
Example 5
Source File: xaHelper.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
private void handleException(Throwable t) throws SQLException
{
	if (t instanceof SQLException)
	{
		// let ij handle it
		throw (SQLException)t;
	}
	if (t instanceof XAException)
	{
		int errorCode = ((XAException)t).errorCode;
		String error = LocalizedResource.getMessage("IJ_IlleValu");

		// XA_RBBASE 100
		// XA_RBROLLBACK 100
		// XA_RBCOMMFAIL 101
		// XA_RBDEADLOCK 102
		// XA_RBINTEGRITY 103
		// XA_RBOTHER 104
		// XA_RBPROTO 105
		// XA_RBTIMEOUT 106
		// XA_RBTRANSIENT 107
		// XA_RBEND 107
		//
		// XA_RDONLY 3
		// XA_RETRY 4
		// XA_HEURMIX 5
		// XA_HEURRB 6
		// XA_HEURCOM 7
		// XA_HEURHAZ 8
		// XA_NOMIGRATE 9
		//
		// XAER_ASYNC -2
		// XAER_RMERR -3
		// XAER_NOTA -4
		// XAER_INVAL -5
		// XAER_PROTO -6
		// XAER_RMFAIL -7
		// XAER_DUPID -8
		// XAER_OUTSIDE -9

		switch(errorCode)
		{
		case XAException.XA_HEURCOM : error = "XA_HEURCOM "; break;
		case XAException.XA_HEURHAZ : error = "XA_HEURHAZ"; break;
		case XAException.XA_HEURMIX : error = "XA_HEURMIX"; break;
		case XAException.XA_HEURRB : error = "XA_HEURRB "; break;
		case XAException.XA_NOMIGRATE : error = "XA_NOMIGRATE "; break;
			// case XAException.XA_RBBASE : error = "XA_RBBASE "; break;
		case XAException.XA_RBCOMMFAIL : error = "XA_RBCOMMFAIL "; break;
		case XAException.XA_RBDEADLOCK : error = "XA_RBDEADLOCK "; break;
			// case XAException.XA_RBEND : error = "XA_RBEND "; break;
		case XAException.XA_RBINTEGRITY : error = "XA_RBINTEGRITY "; break;
		case XAException.XA_RBOTHER : error = "XA_RBOTHER "; break;
		case XAException.XA_RBPROTO : error = "XA_RBPROTO "; break;
		case XAException.XA_RBROLLBACK : error = "XA_RBROLLBACK "; break;
		case XAException.XA_RBTIMEOUT : error = "XA_RBTIMEOUT "; break;
		case XAException.XA_RBTRANSIENT : error = "XA_RBTRANSIENT "; break;
		case XAException.XA_RDONLY : error = "XA_RDONLY "; break;
		case XAException.XA_RETRY : error = "XA_RETRY "; break;
		case XAException.XAER_ASYNC : error = "XAER_ASYNC "; break;
		case XAException.XAER_DUPID : error = "XAER_DUPID "; break;
		case XAException.XAER_INVAL : error = "XAER_INVAL "; break;
		case XAException.XAER_NOTA : error = "XAER_NOTA "; break;
		case XAException.XAER_OUTSIDE : error = "XAER_OUTSIDE "; break;
		case XAException.XAER_PROTO : error = "XAER_PROTO "; break;
		case XAException.XAER_RMERR : error = "XAER_RMERR "; break;
		case XAException.XAER_RMFAIL : error = "XAER_RMFAIL "; break;
		}
		//t.printStackTrace(System.out);
		throw new ijException(error);

	}
	else // StandardException or run time exception, log it first
	{
		String info = LocalizedResource.getMessage("IJ_01SeeLog", t.toString(), t.getMessage());
		//		t.printStackTrace(System.out);
		throw new ijException(info);
	}
}
 
Example 6
Source File: xaHelper.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
private void handleException(Throwable t) throws SQLException
{
	if (t instanceof SQLException)
	{
		// let ij handle it
		throw (SQLException)t;
	}
	if (t instanceof XAException)
	{
		int errorCode = ((XAException)t).errorCode;
		String error = LocalizedResource.getMessage("IJ_IlleValu");

		// XA_RBBASE 100
		// XA_RBROLLBACK 100
		// XA_RBCOMMFAIL 101
		// XA_RBDEADLOCK 102
		// XA_RBINTEGRITY 103
		// XA_RBOTHER 104
		// XA_RBPROTO 105
		// XA_RBTIMEOUT 106
		// XA_RBTRANSIENT 107
		// XA_RBEND 107
		//
		// XA_RDONLY 3
		// XA_RETRY 4
		// XA_HEURMIX 5
		// XA_HEURRB 6
		// XA_HEURCOM 7
		// XA_HEURHAZ 8
		// XA_NOMIGRATE 9
		//
		// XAER_ASYNC -2
		// XAER_RMERR -3
		// XAER_NOTA -4
		// XAER_INVAL -5
		// XAER_PROTO -6
		// XAER_RMFAIL -7
		// XAER_DUPID -8
		// XAER_OUTSIDE -9

		switch(errorCode)
		{
		case XAException.XA_HEURCOM : error = "XA_HEURCOM "; break;
		case XAException.XA_HEURHAZ : error = "XA_HEURHAZ"; break;
		case XAException.XA_HEURMIX : error = "XA_HEURMIX"; break;
		case XAException.XA_HEURRB : error = "XA_HEURRB "; break;
		case XAException.XA_NOMIGRATE : error = "XA_NOMIGRATE "; break;
			// case XAException.XA_RBBASE : error = "XA_RBBASE "; break;
		case XAException.XA_RBCOMMFAIL : error = "XA_RBCOMMFAIL "; break;
		case XAException.XA_RBDEADLOCK : error = "XA_RBDEADLOCK "; break;
			// case XAException.XA_RBEND : error = "XA_RBEND "; break;
		case XAException.XA_RBINTEGRITY : error = "XA_RBINTEGRITY "; break;
		case XAException.XA_RBOTHER : error = "XA_RBOTHER "; break;
		case XAException.XA_RBPROTO : error = "XA_RBPROTO "; break;
		case XAException.XA_RBROLLBACK : error = "XA_RBROLLBACK "; break;
		case XAException.XA_RBTIMEOUT : error = "XA_RBTIMEOUT "; break;
		case XAException.XA_RBTRANSIENT : error = "XA_RBTRANSIENT "; break;
		case XAException.XA_RDONLY : error = "XA_RDONLY "; break;
		case XAException.XA_RETRY : error = "XA_RETRY "; break;
		case XAException.XAER_ASYNC : error = "XAER_ASYNC "; break;
		case XAException.XAER_DUPID : error = "XAER_DUPID "; break;
		case XAException.XAER_INVAL : error = "XAER_INVAL "; break;
		case XAException.XAER_NOTA : error = "XAER_NOTA "; break;
		case XAException.XAER_OUTSIDE : error = "XAER_OUTSIDE "; break;
		case XAException.XAER_PROTO : error = "XAER_PROTO "; break;
		case XAException.XAER_RMERR : error = "XAER_RMERR "; break;
		case XAException.XAER_RMFAIL : error = "XAER_RMFAIL "; break;
		}
		//t.printStackTrace(System.out);
		throw new ijException(error);

	}
	else // StandardException or run time exception, log it first
	{
		String info = LocalizedResource.getMessage("IJ_01SeeLog", t.toString(), t.getMessage());
		//		t.printStackTrace(System.out);
		throw new ijException(info);
	}
}
 
Example 7
Source File: XATerminatorOptd.java    From ByteJTA with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void fireOnePhaseCommit(Xid xid) throws XAException {
	if (archive.isCommitted() && archive.isRolledback()) {
		throw new XAException(XAException.XA_HEURMIX);
	} else if (archive.isCommitted()) {
		return;
	} else if (archive.isReadonly()) {
		throw new XAException(XAException.XA_RDONLY); // XAException.XAER_NOTA
	} else if (archive.isRolledback()) {
		throw new XAException(XAException.XA_HEURRB);
	}

	TransactionLogger transactionLogger = this.beanFactory.getTransactionLogger();

	boolean updateRequired = true;
	try {
		archive.commit(archive.getXid(), true);
		archive.setCommitted(true);
		archive.setCompleted(true);

		logger.info("{}> commit: xares= {}, branch= {}, opc= {}",
				ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()), archive,
				ByteUtils.byteArrayToString(archive.getXid().getBranchQualifier()), false);
	} catch (XAException xaex) {
		switch (xaex.errorCode) {
		case XAException.XA_HEURCOM:
			archive.setHeuristic(true);
			archive.setCommitted(true);
			archive.setCompleted(true);
			break;
		case XAException.XA_HEURMIX:
			archive.setHeuristic(true);
			archive.setCommitted(true);
			archive.setRolledback(true);
			archive.setCompleted(true);
			throw xaex;
		case XAException.XA_HEURRB:
			archive.setHeuristic(true);
			archive.setRolledback(true);
			archive.setCompleted(true);
			throw xaex;
		case XAException.XA_HEURHAZ:
			archive.setHeuristic(true);
			throw xaex;
		case XAException.XAER_RMFAIL:
			logger.warn("An error occurred in one phase commit: {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			updateRequired = false;
			throw new XAException(XAException.XA_HEURHAZ);
		case XAException.XAER_NOTA:
		case XAException.XAER_INVAL:
		case XAException.XAER_PROTO:
			logger.warn("An error occurred in one phase commit: {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			updateRequired = false;
			throw new XAException(XAException.XAER_RMERR);
		case XAException.XAER_RMERR:
		case XAException.XA_RBCOMMFAIL:
		case XAException.XA_RBDEADLOCK:
		case XAException.XA_RBINTEGRITY:
		case XAException.XA_RBOTHER:
		case XAException.XA_RBPROTO:
		case XAException.XA_RBROLLBACK:
		case XAException.XA_RBTIMEOUT:
		case XAException.XA_RBTRANSIENT:
		default:
			logger.warn("An error occurred in one phase commit: {}, transaction has been rolled back!",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()));
			archive.setRolledback(true);
			archive.setCompleted(true);
			throw new XAException(XAException.XA_HEURRB);
		}
	} catch (RuntimeException rex) {
		logger.error("{}> Error occurred while committing xa-resource: xares= {}, branch= {}",
				ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()), archive,
				ByteUtils.byteArrayToString(archive.getXid().getBranchQualifier()), rex);
		updateRequired = false;
		throw new XAException(XAException.XA_HEURHAZ);
	} finally {
		if (updateRequired) {
			transactionLogger.updateParticipant(archive);
		}
	}
}
 
Example 8
Source File: XATerminatorImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void fireOnePhaseCommit(Xid xid) throws XAException {

		if (this.resources.size() == 0) {
			throw new XAException(XAException.XA_RDONLY);
		} else if (this.resources.size() > 1) {
			this.rollback(xid);
			throw new XAException(XAException.XA_HEURRB);
		}

		TransactionLogger transactionLogger = this.beanFactory.getTransactionLogger();

		XAResourceArchive archive = this.resources.get(0);

		if (archive.isCommitted() && archive.isRolledback()) {
			throw new XAException(XAException.XA_HEURMIX);
		} else if (archive.isCommitted()) {
			return;
		} else if (archive.isReadonly()) {
			throw new XAException(XAException.XA_RDONLY);
		} else if (archive.isRolledback()) {
			throw new XAException(XAException.XA_HEURRB);
		}

		boolean updateRequired = true;
		try {
			this.invokeOnePhaseCommit(archive);

			archive.setCommitted(true);
			archive.setCompleted(true);

			logger.info("{}> commit: xares= {}, branch= {}, opc= {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()), archive,
					ByteUtils.byteArrayToString(archive.getXid().getBranchQualifier()), true);
		} catch (XAException xaex) {
			logger.error("{}> Error occurred while committing xa-resource: xares= {}, branch= {}, code= {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()), archive,
					ByteUtils.byteArrayToString(archive.getXid().getBranchQualifier()), xaex.errorCode, xaex);

			switch (xaex.errorCode) {
			case XAException.XA_HEURCOM:
				archive.setHeuristic(true);
				archive.setCommitted(true);
				archive.setCompleted(true);
				break;
			case XAException.XA_HEURHAZ:
				archive.setHeuristic(true);
				throw xaex;
			case XAException.XA_HEURMIX:
				archive.setHeuristic(true);
				archive.setCommitted(true);
				archive.setRolledback(true);
				archive.setCompleted(true);
				throw xaex;
			case XAException.XA_HEURRB:
				archive.setHeuristic(true);
				archive.setRolledback(true);
				archive.setCompleted(true);
				throw xaex;
			case XAException.XAER_RMFAIL:
				updateRequired = false;
				throw new XAException(XAException.XA_HEURHAZ);
			case XAException.XAER_RMERR:
			default:
				updateRequired = false;
				throw new XAException(XAException.XAER_RMERR);
			}
		} catch (RuntimeException rex) {
			logger.error("{}> Error occurred while committing xa-resource: xares= {}, branch= {}",
					ByteUtils.byteArrayToString(archive.getXid().getGlobalTransactionId()), archive,
					ByteUtils.byteArrayToString(archive.getXid().getBranchQualifier()), rex);
			updateRequired = false;
			throw new XAException(XAException.XA_HEURHAZ);
		} finally {
			if (updateRequired) {
				transactionLogger.updateParticipant(archive);
			}
		}
	}
 
Example 9
Source File: XATerminatorImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void invokeTwoPhaseCommit(XAResourceArchive archive) throws XAException {
	try {
		archive.commit(archive.getXid(), false);
	} catch (XAException xaex) {
		// * @exception XAException An error has occurred. Possible XAExceptions
		// * are XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR,
		// * XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
		// * <P>If the resource manager did not commit the transaction and the
		// * parameter onePhase is set to true, the resource manager may throw
		// * one of the XA_RB* exceptions. Upon return, the resource manager has
		// * rolled back the branch's work and has released all held resources.
		switch (xaex.errorCode) {
		case XAException.XA_HEURHAZ:
			// OSI-TP: The condition that arises when, as a result of communication failure with a
			// subordinate, the bound data of the subordinate's subtree are in an unknown state.

			// XA: Due to some failure, the work done on behalf of the specified
			// transaction branch may have been heuristically completed.
		case XAException.XA_HEURMIX:
			// Due to a heuristic decision, the work done on behalf of the specified
			// transaction branch was partially committed and partially rolled back.
		case XAException.XA_HEURCOM:
			// Due to a heuristic decision, the work done on behalf of
			// the specified transaction branch was committed.
		case XAException.XA_HEURRB:
			// Due to a heuristic decision, the work done on behalf of
			// the specified transaction branch was rolled back.
			throw xaex;
		case XAException.XAER_NOTA:
			// The specified XID is not known by the resource manager.
			throw new XAException(XAException.XA_RDONLY); // read-only
		case XAException.XAER_RMFAIL:
			// An error occurred that makes the resource manager unavailable.
			throw xaex;
		case XAException.XAER_INVAL:
			// Invalid arguments were specified.
		case XAException.XAER_PROTO:
			// The routine was invoked in an improper context.
			XAException error = new XAException(XAException.XAER_RMERR);
			error.initCause(xaex);
			throw error;
		case XAException.XAER_RMERR:
			// An error occurred in committing the work performed on behalf of the transaction
			// branch and the branch’s work has been rolled back. Note that returning this error
			// signals a catastrophic event to a transaction manager since other resource
			// managers may successfully commit their work on behalf of this branch. This error
			// should be returned only when a resource manager concludes that it can never
			// commit the branch and that it cannot hold the branch’s resources in a prepared
			// state. Otherwise, [XA_RETRY] should be returned.
			throw xaex; // TODO XA_RETRY is not defined by the JTA specification
		default:// XA_RB*
			XAException xarb = new XAException(XAException.XA_HEURRB);
			xarb.initCause(xaex);
			throw xarb;
		}
	}
}
 
Example 10
Source File: XATerminatorImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void invokeRollback(XAResourceArchive archive) throws XAException {
	try {
		archive.rollback(archive.getXid());
	} catch (XAException xaex) {
		// * @exception XAException An error has occurred. Possible XAExceptions are
		// * XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR, XAER_RMFAIL,
		// * XAER_NOTA, XAER_INVAL, or XAER_PROTO.
		// * <p>If the transaction branch is already marked rollback-only the
		// * resource manager may throw one of the XA_RB* exceptions. Upon return,
		// * the resource manager has rolled back the branch's work and has released
		// * all held resources.
		switch (xaex.errorCode) {
		case XAException.XA_HEURHAZ:
			// Due to some failure, the work done on behalf of the specified transaction branch
			// may have been heuristically completed. A resource manager may return this
			// value only if it has successfully prepared xid.
		case XAException.XA_HEURMIX:
			// Due to a heuristic decision, the work done on behalf of the specified transaction
			// branch was partially committed and partially rolled back. A resource manager
			// may return this value only if it has successfully prepared xid.
		case XAException.XA_HEURCOM:
			// Due to a heuristic decision, the work done on behalf of the specified transaction
			// branch was committed. A resource manager may return this value only if it has
			// successfully prepared xid.
		case XAException.XA_HEURRB:
			// Due to a heuristic decision, the work done on behalf of the specified transaction
			// branch was rolled back. A resource manager may return this value only if it has
			// successfully prepared xid.
			throw xaex;
		case XAException.XAER_RMFAIL:
			// An error occurred that makes the resource manager unavailable.
			XAException xrhaz = new XAException(XAException.XA_HEURHAZ);
			xrhaz.initCause(xaex);
			throw xrhaz;
		case XAException.XAER_NOTA:
			// The specified XID is not known by the resource manager.
			if (archive.isReadonly()) {
				throw new XAException(XAException.XA_RDONLY);
			} else if (archive.getVote() == XAResourceArchive.DEFAULT_VOTE) {
				break; // rolled back
			} else if (archive.getVote() == XAResource.XA_RDONLY) {
				throw new XAException(XAException.XA_RDONLY);
			} else if (archive.getVote() == XAResource.XA_OK) {
				throw new XAException(XAException.XAER_RMERR);
			} else {
				throw new XAException(XAException.XAER_RMERR);
			}
		case XAException.XAER_PROTO:
			// The routine was invoked in an improper context.
		case XAException.XAER_INVAL:
			// Invalid arguments were specified.
			throw new XAException(XAException.XAER_RMERR);
		case XAException.XAER_RMERR:
			// An error occurred in rolling back the transaction branch. The resource manager is
			// free to forget about the branch when returning this error so long as all accessing
			// threads of control have been notified of the branch’s state.
		default: // XA_RB*
			// The resource manager has rolled back the transaction branch’s work and has
			// released all held resources. These values are typically returned when the
			// branch was already marked rollback-only.
			XAException xarb = new XAException(XAException.XA_HEURRB);
			xarb.initCause(xaex);
			throw xarb;
		}
	}
}
 
Example 11
Source File: XASupport.java    From jTDS with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Construct and throw an <code>XAException</code> with an explanatory message and the XA error code set.
 *
 * @param errorCode the XA Error code
 * @exception javax.transaction.xa.XAException
 *             the constructed exception
 */
public static void raiseXAException(int errorCode)
        throws XAException {
    String err = "xaerunknown";
    switch (errorCode) {
        case XAException.XA_RBROLLBACK:
            err = "xarbrollback";
            break;
        case XAException.XA_RBCOMMFAIL:
            err = "xarbcommfail";
            break;
        case XAException.XA_RBDEADLOCK:
            err = "xarbdeadlock";
            break;
        case XAException.XA_RBINTEGRITY:
            err = "xarbintegrity";
            break;
        case XAException.XA_RBOTHER:
            err = "xarbother";
            break;
        case XAException.XA_RBPROTO:
            err = "xarbproto";
            break;
        case XAException.XA_RBTIMEOUT:
            err = "xarbtimeout";
            break;
        case XAException.XA_RBTRANSIENT:
            err = "xarbtransient";
            break;
        case XAException.XA_NOMIGRATE:
            err = "xanomigrate";
            break;
        case XAException.XA_HEURHAZ:
            err = "xaheurhaz";
            break;
        case XAException.XA_HEURCOM:
            err = "xaheurcom";
            break;
        case XAException.XA_HEURRB:
            err = "xaheurrb";
            break;
        case XAException.XA_HEURMIX:
            err = "xaheurmix";
            break;
        case XAException.XA_RETRY:
            err = "xaretry";
            break;
        case XAException.XA_RDONLY:
            err = "xardonly";
            break;
        case XAException.XAER_ASYNC:
            err = "xaerasync";
            break;
        case XAException.XAER_NOTA:
            err = "xaernota";
            break;
        case XAException.XAER_INVAL:
            err = "xaerinval";
            break;
        case XAException.XAER_PROTO:
            err = "xaerproto";
            break;
        case XAException.XAER_RMERR:
            err = "xaerrmerr";
            break;
        case XAException.XAER_RMFAIL:
            err = "xaerrmfail";
            break;
        case XAException.XAER_DUPID:
            err = "xaerdupid";
            break;
        case XAException.XAER_OUTSIDE:
            err = "xaeroutside";
            break;
    }
    XAException e = new XAException(Messages.get("error.xaexception." + err));
    e.errorCode = errorCode;
    Logger.println("XAException: " + e.getMessage());
    throw e;
}
 
Example 12
Source File: xaHelper.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
private void handleException(Throwable t) throws SQLException
{
	if (t instanceof SQLException)
	{
		// let ij handle it
		throw (SQLException)t;
	}
	if (t instanceof XAException)
	{
		int errorCode = ((XAException)t).errorCode;
		String error = LocalizedResource.getMessage("IJ_IlleValu");

		// XA_RBBASE 100
		// XA_RBROLLBACK 100
		// XA_RBCOMMFAIL 101
		// XA_RBDEADLOCK 102
		// XA_RBINTEGRITY 103
		// XA_RBOTHER 104
		// XA_RBPROTO 105
		// XA_RBTIMEOUT 106
		// XA_RBTRANSIENT 107
		// XA_RBEND 107
		//
		// XA_RDONLY 3
		// XA_RETRY 4
		// XA_HEURMIX 5
		// XA_HEURRB 6
		// XA_HEURCOM 7
		// XA_HEURHAZ 8
		// XA_NOMIGRATE 9
		//
		// XAER_ASYNC -2
		// XAER_RMERR -3
		// XAER_NOTA -4
		// XAER_INVAL -5
		// XAER_PROTO -6
		// XAER_RMFAIL -7
		// XAER_DUPID -8
		// XAER_OUTSIDE -9

		switch(errorCode)
		{
		case XAException.XA_HEURCOM : error = "XA_HEURCOM "; break;
		case XAException.XA_HEURHAZ : error = "XA_HEURHAZ"; break;
		case XAException.XA_HEURMIX : error = "XA_HEURMIX"; break;
		case XAException.XA_HEURRB : error = "XA_HEURRB "; break;
		case XAException.XA_NOMIGRATE : error = "XA_NOMIGRATE "; break;
			// case XAException.XA_RBBASE : error = "XA_RBBASE "; break;
		case XAException.XA_RBCOMMFAIL : error = "XA_RBCOMMFAIL "; break;
		case XAException.XA_RBDEADLOCK : error = "XA_RBDEADLOCK "; break;
			// case XAException.XA_RBEND : error = "XA_RBEND "; break;
		case XAException.XA_RBINTEGRITY : error = "XA_RBINTEGRITY "; break;
		case XAException.XA_RBOTHER : error = "XA_RBOTHER "; break;
		case XAException.XA_RBPROTO : error = "XA_RBPROTO "; break;
		case XAException.XA_RBROLLBACK : error = "XA_RBROLLBACK "; break;
		case XAException.XA_RBTIMEOUT : error = "XA_RBTIMEOUT "; break;
		case XAException.XA_RBTRANSIENT : error = "XA_RBTRANSIENT "; break;
		case XAException.XA_RDONLY : error = "XA_RDONLY "; break;
		case XAException.XA_RETRY : error = "XA_RETRY "; break;
		case XAException.XAER_ASYNC : error = "XAER_ASYNC "; break;
		case XAException.XAER_DUPID : error = "XAER_DUPID "; break;
		case XAException.XAER_INVAL : error = "XAER_INVAL "; break;
		case XAException.XAER_NOTA : error = "XAER_NOTA "; break;
		case XAException.XAER_OUTSIDE : error = "XAER_OUTSIDE "; break;
		case XAException.XAER_PROTO : error = "XAER_PROTO "; break;
		case XAException.XAER_RMERR : error = "XAER_RMERR "; break;
		case XAException.XAER_RMFAIL : error = "XAER_RMFAIL "; break;
		}
		//t.printStackTrace(System.out);
		throw new ijException(error);

	}
	else // StandardException or run time exception, log it first
	{
		String info = LocalizedResource.getMessage("IJ_01SeeLog", t.toString(), t.getMessage());
		//		t.printStackTrace(System.out);
		throw new ijException(info);
	}
}