Example usage for javax.transaction SystemException SystemException

List of usage examples for javax.transaction SystemException SystemException

Introduction

In this page you can find the example usage for javax.transaction SystemException SystemException.

Prototype

public SystemException() 

Source Link

Usage

From source file:com._4dconcept.springframework.data.marklogic.datasource.DatabaseConnectorJtaTransactionTest.java

private void doTestJtaTransactionWithPropagationRequiresNewAndBeginException(boolean suspendException,
        final boolean openOuterConnection, final boolean useTransactionAwareContentSource) throws Exception {

    given(userTransaction.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE,
            Status.STATUS_ACTIVE);
    if (suspendException) {
        given(transactionManager.suspend()).willThrow(new SystemException());
    } else {/*ww w.ja va 2  s.c  om*/
        given(transactionManager.suspend()).willReturn(transaction);
        willThrow(new SystemException()).given(userTransaction).begin();
    }

    given(session.getTransactionMode()).willReturn(Session.TransactionMode.QUERY);

    final ContentSource dsToUse = useTransactionAwareContentSource
            ? new TransactionAwareContentSourceProxy(contentSource)
            : contentSource;
    if (dsToUse instanceof TransactionAwareContentSourceProxy) {
        ((TransactionAwareContentSourceProxy) dsToUse).setReobtainTransactionalSessions(true);
    }

    JtaTransactionManager ptm = new JtaTransactionManager(userTransaction, transactionManager);
    final TransactionTemplate tt = new TransactionTemplate(ptm);
    tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(dsToUse));
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());

    try {
        tt.execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) throws RuntimeException {
                assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(dsToUse));
                assertTrue("JTA synchronizations active",
                        TransactionSynchronizationManager.isSynchronizationActive());
                assertTrue("Is new transaction", status.isNewTransaction());

                Session c = ContentSourceUtils.getSession(dsToUse);
                assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(dsToUse));
                c.getTransactionMode();
                ContentSourceUtils.releaseSession(c, dsToUse);

                c = ContentSourceUtils.getSession(dsToUse);
                assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(dsToUse));
                if (!openOuterConnection) {
                    ContentSourceUtils.releaseSession(c, dsToUse);
                }

                try {
                    tt.execute(new TransactionCallbackWithoutResult() {
                        @Override
                        protected void doInTransactionWithoutResult(TransactionStatus status)
                                throws RuntimeException {
                            assertTrue("Hasn't thread session",
                                    !TransactionSynchronizationManager.hasResource(dsToUse));
                            assertTrue("JTA synchronizations active",
                                    TransactionSynchronizationManager.isSynchronizationActive());
                            assertTrue("Is new transaction", status.isNewTransaction());

                            Session c = ContentSourceUtils.getSession(dsToUse);
                            assertTrue("Has thread session",
                                    TransactionSynchronizationManager.hasResource(dsToUse));
                            ContentSourceUtils.releaseSession(c, dsToUse);

                            c = ContentSourceUtils.getSession(dsToUse);
                            assertTrue("Has thread session",
                                    TransactionSynchronizationManager.hasResource(dsToUse));
                            ContentSourceUtils.releaseSession(c, dsToUse);
                        }
                    });
                } finally {
                    if (openOuterConnection) {
                        c.getTransactionMode();
                        ContentSourceUtils.releaseSession(c, dsToUse);

                    }
                }
            }
        });

        fail("Should have thrown TransactionException");
    } catch (TransactionException ex) {
        // expected
    }

    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(dsToUse));
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());

    verify(userTransaction).begin();
    if (suspendException) {
        verify(userTransaction).rollback();
    }

    if (suspendException) {
        verify(session, atLeastOnce()).close();
    } else {
        verify(session, never()).close();
    }
}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

private synchronized void fireNativeParticipantConfirm() throws SystemException {
    boolean errorExists = false;

    ContainerContext container = this.beanFactory.getContainerContext();
    for (int i = this.archiveList.size() - 1; i >= 0; i--) {
        CompensableArchive current = this.archiveList.get(i);
        if (current.isConfirmed()) {
            continue;
        }/*from  ww w.  ja v  a2 s.  com*/

        try {
            this.positive = true;
            this.archive = current;
            CompensableInvocation invocation = current.getCompensable();
            if (invocation == null) {
                errorExists = true;
                logger.error(
                        "{}| error occurred while confirming service: {}, please check whether the params of method(compensable-service) supports serialization.",
                        ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()));
            } else if (StringUtils.isNotBlank(invocation.getConfirmableKey())) {
                container.confirm(invocation);
            } else {
                current.setConfirmed(true);
                logger.info("{}| confirm: identifier= {}, resourceKey= {}, resourceXid= {}.",
                        ByteUtils.byteArrayToString(transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()),
                        current.getCompensableResourceKey(), current.getCompensableXid());
            }
        } catch (RuntimeException rex) {
            errorExists = true;
            logger.error("{}| error occurred while confirming service: {}",
                    ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                    this.archive, rex);
        } finally {
            this.archive = null;
            this.positive = null;
        }
    }

    if (errorExists) {
        throw new SystemException();
    }

}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

private synchronized void fireRemoteParticipantConfirm()
        throws HeuristicMixedException, HeuristicRollbackException, SystemException {
    boolean commitExists = false;
    boolean rollbackExists = false;
    boolean errorExists = false;

    for (int i = 0; i < this.resourceList.size(); i++) {
        XAResourceArchive current = this.resourceList.get(i);
        if (current.isCommitted()) {
            commitExists = true;//from  ww w.  jav a2s .c o  m
            continue;
        }

        CompensableLogger transactionLogger = this.beanFactory.getCompensableLogger();
        XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
        TransactionXid branchXid = (TransactionXid) current.getXid();
        TransactionXid globalXid = xidFactory.createGlobalXid(branchXid.getGlobalTransactionId());
        try {
            current.commit(globalXid, true);
            commitExists = true;

            current.setCommitted(true);
            current.setCompleted(true);
            transactionLogger.updateCoordinator(current);

            logger.info("{}| confirm remote branch: {}",
                    ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()),
                    current.getDescriptor().getIdentifier());
        } catch (XAException ex) {
            switch (ex.errorCode) {
            case XAException.XAER_NOTA:
                logger.warn("{}| error occurred while confirming remote branch: {}, transaction is not exists!",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()),
                        current.getDescriptor().getIdentifier());
                break;
            case XAException.XA_HEURCOM:
                commitExists = true;

                current.setCommitted(true);
                current.setHeuristic(false);
                current.setCompleted(true);
                transactionLogger.updateCoordinator(current);

                logger.info("{}| confirm remote branch: {}",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()),
                        current.getDescriptor().getIdentifier());
                break;
            case XAException.XA_HEURRB:
                rollbackExists = true;

                current.setRolledback(true);
                current.setHeuristic(false);
                current.setCompleted(true);
                transactionLogger.updateCoordinator(current);

                logger.error("{}| error occurred while confirming remote branch: {}",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), this.archive, ex);
                break;
            case XAException.XA_HEURMIX:
                // should never happen
                commitExists = true;
                rollbackExists = true;

                current.setHeuristic(true);
                // current.setCommitted(true);
                // current.setRolledback(true);
                // current.setCompleted(true);
                transactionLogger.updateCoordinator(current);

                logger.error("{}| error occurred while confirming remote branch: {}",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), this.archive, ex);
                break;
            default:
                errorExists = false;
                logger.error("{}| error occurred while confirming remote branch: {}",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), this.archive, ex);
            }

        } catch (RuntimeException rex) {
            errorExists = false;
            logger.error("{}| error occurred while confirming branch: {}",
                    ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), this.archive, rex);
        }
    }

    if (commitExists && rollbackExists) {
        throw new HeuristicMixedException();
    } else if (rollbackExists) {
        throw new HeuristicRollbackException();
    } else if (errorExists) {
        throw new SystemException();
    }

}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

private synchronized void fireNativeParticipantCancel() throws SystemException {
    boolean errorExists = false;

    ContainerContext container = this.beanFactory.getContainerContext();
    for (int i = this.archiveList.size() - 1; i >= 0; i--) {
        CompensableArchive current = this.archiveList.get(i);
        if (current.isCancelled()) {
            continue;
        }/*from  w w  w.  j av a 2  s.  co m*/

        try {
            this.positive = false;
            this.archive = current;
            CompensableInvocation invocation = current.getCompensable();
            if (current.isTried() == false) {
                logger.info(
                        "{}| The operation in try phase is rolled back, so the cancel operation is ignored, compensable service: {}.",
                        ByteUtils.byteArrayToString(transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()));
            } else if (invocation == null) {
                errorExists = true;
                logger.error(
                        "{}| error occurred while cancelling service: {}, please check whether the params of method(compensable-service) supports serialization.",
                        ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()));
            } else if (StringUtils.isNotBlank(invocation.getCancellableKey())) {
                container.cancel(invocation);
            } else {
                this.archive.setCancelled(true);
                logger.info("{}| cancel: identifier= {}, resourceKey= {}, resourceXid= {}.",
                        ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()),
                        current.getCompensableResourceKey(), current.getCompensableXid());
            }
        } catch (RuntimeException rex) {
            errorExists = true;
            logger.error("{}| error occurred while cancelling service: {}",
                    ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                    this.archive, rex);
        } finally {
            this.archive = null;
            this.positive = null;
        }
    }

    if (errorExists) {
        throw new SystemException();
    }

}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

private synchronized void fireRemoteParticipantCancel() throws SystemException {
    boolean errorExists = false;

    for (int i = 0; i < this.resourceList.size(); i++) {
        XAResourceArchive current = this.resourceList.get(i);
        if (current.isRolledback()) {
            continue;
        }//from  ww  w .  j  av a 2 s. c om

        CompensableLogger transactionLogger = this.beanFactory.getCompensableLogger();
        XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
        TransactionXid branchXid = (TransactionXid) current.getXid();
        TransactionXid globalXid = xidFactory.createGlobalXid(branchXid.getGlobalTransactionId());
        try {
            current.rollback(globalXid);

            current.setRolledback(true);
            current.setCompleted(true);
            transactionLogger.updateCoordinator(current);

            logger.info("{}| cancel remote branch: {}",
                    ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()),
                    current.getDescriptor().getIdentifier());
        } catch (XAException ex) {
            switch (ex.errorCode) {
            case XAException.XAER_NOTA:
                logger.warn("{}| error occurred while cancelling remote branch: {}, transaction is not exists!",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()),
                        current.getDescriptor().getIdentifier());
                break;
            default:
                errorExists = true;
                logger.error("{}| error occurred while cancelling remote branch: {}",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, ex);
            }

        } catch (RuntimeException rex) {
            errorExists = true;
            logger.error("{}| error occurred while cancelling remote branch: {}",
                    ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, rex);
        }
    }

    if (errorExists) {
        throw new SystemException();
    }

}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

public void resume() throws SystemException {
    throw new SystemException();
}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

public void suspend() throws SystemException {
    throw new SystemException();
}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

private synchronized void fireNativeParticipantRecoveryConfirmForRecoveredTransaction() throws SystemException {
    boolean errorExists = false;

    ContainerContext container = this.beanFactory.getContainerContext();
    XAResourceDeserializer resourceDeserializer = this.beanFactory.getResourceDeserializer();
    CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger();

    boolean previouConfirmed = false;
    for (int i = this.archiveList.size() - 1; i >= 0; i--) {
        CompensableArchive current = this.archiveList.get(i);
        boolean currentConfirmed = current.isConfirmed();

        if (currentConfirmed) {
            continue;
        }//from  w  ww.j  a  va  2s  .  c o m

        TransactionXid compensableXid = (TransactionXid) current.getCompensableXid();
        try {
            this.positive = true;
            this.archive = current;

            String identifier = current.getCompensableResourceKey();
            if (StringUtils.isBlank(identifier)) {
                if (previouConfirmed) {
                    logger.warn(
                            "There is no valid resource participated in the current branch transaction, the status of the current branch transaction is unknown!");
                } else {
                    logger.debug("There is no valid resource participated in the current branch transaction!");
                }
            } else {
                XAResource xares = resourceDeserializer.deserialize(identifier);
                if (RecoveredResource.class.isInstance(xares)) {
                    RecoveredResource resource = (RecoveredResource) xares;
                    try {
                        resource.recoverable(compensableXid);
                        current.setConfirmed(true);
                        compensableLogger.updateCompensable(current);
                        continue;
                    } catch (XAException xaex) {
                        switch (xaex.errorCode) {
                        case XAException.XAER_NOTA:
                            break;
                        case XAException.XAER_RMERR:
                            logger.warn(
                                    "The database table 'bytejta' cannot found, the status of the current branch transaction is unknown!");
                            break;
                        case XAException.XAER_RMFAIL:
                            errorExists = true;
                            logger.error(
                                    "{}| error occurred while recovering the branch transaction service: {}",
                                    ByteUtils.byteArrayToString(
                                            this.transactionContext.getXid().getGlobalTransactionId()),
                                    ByteUtils.byteArrayToString(
                                            current.getIdentifier().getGlobalTransactionId()),
                                    xaex);
                            break;
                        default:
                            logger.error(
                                    "Illegal state, the status of the current branch transaction is unknown!");
                        }
                    }
                } else {
                    logger.error("Illegal resources, the status of the current branch transaction is unknown!");
                }
            }

            CompensableInvocation invocation = current.getCompensable();
            if (invocation == null) {
                errorExists = true;
                logger.error(
                        "{}| error occurred while confirming service: {}, please check whether the params of method(compensable-service) supports serialization.",
                        ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()));
            } else if (StringUtils.isNotBlank(invocation.getConfirmableKey())) {
                container.confirm(invocation);
            } else {
                current.setConfirmed(true);
                logger.info("{}| confirm: identifier= {}, resourceKey= {}, resourceXid= {}.",
                        ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()),
                        current.getCompensableResourceKey(), current.getCompensableXid());
            }
        } catch (RuntimeException rex) {
            errorExists = true;

            TransactionXid transactionXid = this.transactionContext.getXid();
            logger.error("{}| error occurred while confirming service: {}",
                    ByteUtils.byteArrayToString(transactionXid.getGlobalTransactionId()), this.archive, rex);
        } finally {
            this.archive = null;
            this.positive = null;

            previouConfirmed = currentConfirmed;
        }

    }

    if (errorExists) {
        throw new SystemException();
    }

}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

private synchronized void fireRemoteParticipantRecoveryConfirm()
        throws HeuristicMixedException, HeuristicRollbackException, SystemException {
    boolean commitExists = false;
    boolean rollbackExists = false;
    boolean errorExists = false;

    for (int i = 0; i < this.resourceList.size(); i++) {
        XAResourceArchive current = this.resourceList.get(i);
        if (current.isCommitted()) {
            commitExists = true;//from   w  w  w .j a va2 s.  c o m
            continue;
        }

        CompensableLogger transactionLogger = this.beanFactory.getCompensableLogger();
        XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
        TransactionXid branchXid = (TransactionXid) current.getXid();
        TransactionXid globalXid = xidFactory.createGlobalXid(branchXid.getGlobalTransactionId());
        try {
            current.recoveryCommit(globalXid);
            commitExists = true;

            current.setCommitted(true);
            current.setCompleted(true);
            transactionLogger.updateCoordinator(current);

            logger.info("{}| recovery-confirm remote branch: {}",
                    ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()),
                    current.getDescriptor().getIdentifier());
        } catch (XAException ex) {
            switch (ex.errorCode) {
            case XAException.XAER_NOTA:
                logger.warn("{}| error occurred while confirming remote branch: {}, transaction is not exists!",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()),
                        current.getDescriptor().getIdentifier());
                break;
            case XAException.XA_HEURCOM:
                current.setCommitted(true);
                current.setHeuristic(false);
                current.setCompleted(true);
                transactionLogger.updateCoordinator(current);

                logger.info("{}| recovery-confirm remote branch: {}",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()),
                        current.getDescriptor().getIdentifier());
                break;
            case XAException.XA_HEURRB:
                rollbackExists = true;

                current.setRolledback(true);
                current.setHeuristic(false);
                current.setCompleted(true);
                transactionLogger.updateCoordinator(current);

                logger.error("{}| error occurred while confirming remote branch: {}",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, ex);
                break;
            case XAException.XA_HEURMIX:
                commitExists = true;
                rollbackExists = true;

                current.setHeuristic(true);
                // current.setCommitted(true);
                // current.setRolledback(true);
                // current.setCompleted(true);
                transactionLogger.updateCoordinator(current);

                logger.error("{}| error occurred while confirming remote branch: {}",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, ex);
                break;
            default:
                errorExists = false;
                logger.error("{}| error occurred while confirming remote branch: {}",
                        ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, ex);
            }

        } catch (RuntimeException rex) {
            errorExists = false;
            logger.error("{}| error occurred while confirming remote branch: {}",
                    ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, rex);
        }
    }

    if (commitExists && rollbackExists) {
        throw new HeuristicMixedException();
    } else if (rollbackExists) {
        throw new HeuristicRollbackException();
    } else if (errorExists) {
        throw new SystemException();
    }

}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

private synchronized void fireNativeParticipantRecoveryCancelForRecoveredTransaction() throws SystemException {
    boolean errorExists = false;

    ContainerContext container = this.beanFactory.getContainerContext();
    XAResourceDeserializer resourceDeserializer = this.beanFactory.getResourceDeserializer();
    CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger();

    boolean previouCancelled = false;
    for (int i = this.archiveList.size() - 1; i >= 0; i--) {
        CompensableArchive current = this.archiveList.get(i);
        boolean currentCancelled = current.isCancelled();

        if (currentCancelled) {
            continue;
        }//from w w w.  j  av  a2s  . c  o m

        if (current.isTried() == false) /* this.transactionContext.isCoordinator() == false && */ {
            String identifier = current.getTransactionResourceKey();
            if (StringUtils.isBlank(identifier)) {
                logger.warn(
                        "There is no valid resource participated in the trying branch transaction, the status of the branch transaction is unknown!");
            } else {
                XAResource xares = resourceDeserializer.deserialize(identifier);
                if (RecoveredResource.class.isInstance(xares)) {
                    RecoveredResource resource = (RecoveredResource) xares;
                    try {
                        resource.recoverable(current.getTransactionXid());
                        current.setTried(true);
                        compensableLogger.updateCompensable(current);
                    } catch (XAException xaex) {
                        switch (xaex.errorCode) {
                        case XAException.XAER_NOTA:
                            current.setTried(false);
                            continue;
                        case XAException.XAER_RMERR:
                            logger.warn(
                                    "The database table 'bytejta' cannot found, the status of the trying branch transaction is unknown!");
                            break;
                        case XAException.XAER_RMFAIL:
                            errorExists = true;

                            Xid xid = current.getTransactionXid();
                            logger.error("Error occurred while recovering the branch transaction service: {}",
                                    ByteUtils.byteArrayToString(xid.getGlobalTransactionId()), xaex);
                            break;
                        default:
                            logger.error(
                                    "Illegal state, the status of the trying branch transaction is unknown!");
                        }
                    }
                } else {
                    logger.error("Illegal resources, the status of the trying branch transaction is unknown!");
                }
            }
        }

        TransactionXid compensableXid = (TransactionXid) current.getCompensableXid();
        try {
            this.positive = false;
            this.archive = current;

            String identifier = current.getCompensableResourceKey();
            if (StringUtils.isBlank(identifier)) {
                if (previouCancelled) {
                    logger.warn(
                            "There is no valid resource participated in the current branch transaction, the status of the current branch transaction is unknown!");
                } else {
                    logger.debug("There is no valid resource participated in the current branch transaction!");
                }
            } else {
                XAResource xares = resourceDeserializer.deserialize(identifier);
                if (RecoveredResource.class.isInstance(xares)) {
                    RecoveredResource resource = (RecoveredResource) xares;
                    try {
                        resource.recoverable(compensableXid);
                        current.setCancelled(true);
                        compensableLogger.updateCompensable(current);
                        continue;
                    } catch (XAException xaex) {
                        switch (xaex.errorCode) {
                        case XAException.XAER_NOTA:
                            break;
                        case XAException.XAER_RMERR:
                            logger.warn(
                                    "The database table 'bytejta' cannot found, the status of the current branch transaction is unknown!");
                            break;
                        case XAException.XAER_RMFAIL:
                            errorExists = true;
                            logger.error(
                                    "{}| error occurred while recovering the branch transaction service: {}",
                                    ByteUtils.byteArrayToString(
                                            this.transactionContext.getXid().getGlobalTransactionId()),
                                    ByteUtils.byteArrayToString(
                                            current.getIdentifier().getGlobalTransactionId()),
                                    xaex);
                            break;
                        default:
                            logger.error(
                                    "Illegal state, the status of the current branch transaction is unknown!");
                        }
                    }
                } else {
                    logger.error("Illegal resources, the status of the current branch transaction is unknown!");
                }
            }

            CompensableInvocation invocation = current.getCompensable();
            if (current.isTried() == false) {
                logger.info(
                        "{}| the operation in try phase is rolled back, so the cancel operation is ignored, compensable service: {}.",
                        ByteUtils.byteArrayToString(transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()));
            } else if (invocation == null) {
                errorExists = true;
                logger.error(
                        "{}| error occurred while cancelling service: {}, please check whether the params of method(compensable-service) supports serialization.",
                        ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()));
            } else if (StringUtils.isNotBlank(invocation.getCancellableKey())) {
                container.cancel(invocation);
            } else {
                this.archive.setCancelled(true);
                logger.info("{}| cancel: identifier= {}, resourceKey= {}, resourceXid= {}.",
                        ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                        ByteUtils.byteArrayToString(current.getIdentifier().getGlobalTransactionId()),
                        current.getCompensableResourceKey(), current.getCompensableXid());
            }
        } catch (RuntimeException rex) {
            errorExists = true;
            logger.error("{}| error occurred while cancelling service: {}",
                    ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
                    this.archive, rex);
        } finally {
            this.archive = null;
            this.positive = null;

            previouCancelled = currentCancelled;
        }
    }

    if (errorExists) {
        throw new SystemException();
    }

}