Search in sources :

Example 41 with SystemException

use of com.arjuna.wst.SystemException in project narayana by jbosstm.

the class BusinessActivityTerminatorStub method complete.

public void complete() throws FaultedException, UnknownTransactionException, SystemException {
    final MAP map = AddressingHelper.createNotificationContext(MessageId.getMessageId());
    final RequestCallback callback = new RequestCallback();
    final TerminationParticipantProcessor terminationParticipantProcessor = TerminationParticipantProcessor.getProcessor();
    terminationParticipantProcessor.registerCallback(_id, callback);
    try {
        TerminationCoordinatorClient.getClient().sendComplete(_terminationCoordinator, map, new InstanceIdentifier(_id));
        callback.waitUntilTriggered();
    } catch (final Throwable th) {
        throw new SystemException();
    } finally {
        terminationParticipantProcessor.removeCallback(_id);
    }
    if (callback.hasTriggered()) {
        if (callback.receivedCompleted()) {
            return;
        } else if (callback.receivedFaulted()) {
            throw new FaultedException();
        }
        final SoapFault soapFault = callback.getSoapFault();
        if (soapFault != null) {
            final QName subcode = soapFault.getSubcode();
            if (ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME.equals(subcode)) {
                throw new UnknownTransactionException();
            }
        }
    }
    throw new SystemException();
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) SystemException(com.arjuna.wst.SystemException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) QName(javax.xml.namespace.QName) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) FaultedException(com.arjuna.wst.FaultedException) MAP(org.jboss.ws.api.addressing.MAP) TerminationParticipantProcessor(com.arjuna.webservices11.wsarjtx.processors.TerminationParticipantProcessor)

Example 42 with SystemException

use of com.arjuna.wst.SystemException in project narayana by jbosstm.

the class CompletionRPCStub method commit.

public void commit() throws TransactionRolledBackException, UnknownTransactionException, SystemException {
    final MAP map = AddressingHelper.createNotificationContext(MessageId.getMessageId());
    boolean result;
    try {
        result = CompletionCoordinatorRPCClient.getClient().sendCommit(_completionCoordinator, map);
    } catch (final SoapFault soapFault) {
        if (ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME.equals(soapFault.getSubcode())) {
            throw new UnknownTransactionException(soapFault.getMessage());
        }
        throw new SystemException(soapFault.getMessage());
    } catch (final Exception e) {
        throw new SystemException(e.getMessage());
    } catch (final Throwable th) {
        th.printStackTrace();
        throw new SystemException(th.getMessage());
    }
    if (!result) {
        throw new TransactionRolledBackException();
    }
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) MAP(org.jboss.ws.api.addressing.MAP) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) SystemException(com.arjuna.wst.SystemException)

Example 43 with SystemException

use of com.arjuna.wst.SystemException in project narayana by jbosstm.

the class SubordinateCoordinatorCompletionParticipantStub method close.

public void close() throws WrongStateException, SystemException {
    if (!recovered) {
        int result;
        try {
            result = coordinator.close();
        } catch (com.arjuna.mw.wsas.exceptions.SystemException se) {
            throw new SystemException(se.getMessage());
        }
        if (result != ActionStatus.COMMITTED) {
            throw new SystemException("failed to close subordinate transaction " + coordinatorId);
        }
    } else {
        XTSBARecoveryManager recoveryManager = null;
        boolean isRecoveryScanStarted = false;
        if (coordinator == null) {
            // try fetching coordinator from the recovery manager
            recoveryManager = XTSBARecoveryManager.getRecoveryManager();
            // check whether recovery has started before we check for the presence
            // of the subordinate coordinator
            isRecoveryScanStarted = recoveryManager.isSubordinateCoordinatorRecoveryStarted();
            coordinator = SubordinateBACoordinator.getRecoveredCoordinator(coordinatorId);
        }
        if (coordinator == null) {
            // hmm, still null -- see if we have finished recovery scanning
            if (!isRecoveryScanStarted) {
                // throw an exception causing the commit to be retried later
                throw new SystemException();
            }
        // ok we have no transaction to commit so assume we already committed it and
        // return without error
        } else if (!coordinator.isActivated()) {
            // throw an exception causing the commit to be retried later
            throw new SystemException();
        } else {
            int status = coordinator.status();
            if (status == ActionStatus.PREPARED || status == ActionStatus.COMMITTING) {
                // ok, the commit process was not previously initiated so start it now
                try {
                    coordinator.close();
                    SubordinateBACoordinator.removeActiveProxy(coordinatorId);
                } catch (com.arjuna.mw.wsas.exceptions.SystemException e) {
                    // throw an exception causing the commit to be retried later
                    throw new SystemException();
                }
                status = coordinator.status();
            }
            if (status == ActionStatus.COMMITTING) {
                // throw an exception causing the commit to be retried later
                throw new SystemException();
            }
        }
    }
}
Also used : XTSBARecoveryManager(org.jboss.jbossts.xts.recovery.participant.ba.XTSBARecoveryManager) SystemException(com.arjuna.wst.SystemException)

Example 44 with SystemException

use of com.arjuna.wst.SystemException in project narayana by jbosstm.

the class SubordinateCoordinatorCompletionParticipantStub method compensate.

public void compensate() throws FaultedException, WrongStateException, SystemException {
    if (!recovered) {
        int result = coordinator.cancel();
    // test result and throw a SystemException if the compensate was delayed
    } else {
        XTSBARecoveryManager recoveryManager = null;
        boolean isRecoveryScanStarted = false;
        if (coordinator == null) {
            // try fetching coordinator from the recovery manager
            recoveryManager = XTSBARecoveryManager.getRecoveryManager();
            // check whether recovery has started before we check for the presence
            // of the subordinate coordinator
            isRecoveryScanStarted = recoveryManager.isSubordinateCoordinatorRecoveryStarted();
            coordinator = SubordinateBACoordinator.getRecoveredCoordinator(coordinatorId);
        }
        if (coordinator == null) {
            // hmm, still null -- see if we have finished recovery scanning
            if (!isRecoveryScanStarted) {
                // throw an exception causing the commit to be retried later
                throw new SystemException();
            }
        // ok we have no transaction to commit so assume we already committed it and
        // return without error
        } else if (!coordinator.isActivated()) {
            // throw an exception causing the commit to be retried later
            throw new SystemException();
        } else {
            int status = coordinator.status();
            if (status == ActionStatus.PREPARED || status == ActionStatus.COMMITTING) {
                // ok, the commit process was not previously initiated so start it now
                coordinator.cancel();
                SubordinateBACoordinator.removeActiveProxy(coordinatorId);
                status = coordinator.status();
            }
            if (status == ActionStatus.COMMITTING) {
                // throw an exception causing the commit to be retried later
                throw new SystemException();
            } else if (status != ActionStatus.ABORTED) {
                throw new FaultedException();
            }
        }
    }
}
Also used : XTSBARecoveryManager(org.jboss.jbossts.xts.recovery.participant.ba.XTSBARecoveryManager) SystemException(com.arjuna.wst.SystemException)

Example 45 with SystemException

use of com.arjuna.wst.SystemException in project narayana by jbosstm.

the class UserTransactionStandaloneImple method commitWithoutAck.

private final void commitWithoutAck() throws TransactionRolledBackException, UnknownTransactionException, SecurityException, SystemException, WrongStateException {
    TxContextImple ctx = null;
    String id = null;
    try {
        ctx = (TxContextImple) _ctxManager.suspend();
        if (ctx == null) {
            throw new WrongStateException();
        }
        id = ctx.identifier();
        /*
			 * By default the completionParticipantURL won't be set for an interposed (imported)
			 * bridged transaction. This is fine, because you shouldn't be able to commit that
			 * transaction from a node in the tree, only from the root. So, we can prevent commit
			 * or rollback at this stage. The alternative would be to setup the completionParticipantURL
			 * and throw the exception from the remote coordinator side (see enlistCompletionParticipants
			 * for how to do this).
			 *
			 * The same applies for an interposed subordinate transaction created via beginSubordinate.
			 */
        final W3CEndpointReference completionCoordinator = (W3CEndpointReference) _completionCoordinators.get(id);
        if (completionCoordinator == null)
            throw new WrongStateException();
        CompletionRPCStub completionStub = new CompletionRPCStub(id, completionCoordinator);
        completionStub.commit();
    } catch (SystemException ex) {
        throw ex;
    } catch (TransactionRolledBackException ex) {
        throw ex;
    } catch (UnknownTransactionException ex) {
        throw ex;
    } catch (SecurityException ex) {
        throw ex;
    } catch (WrongStateException ex) {
        throw ex;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new SystemException(ex.toString());
    } finally {
        try {
            if (ctx != null)
                _ctxManager.resume(ctx);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        if (id != null)
            _completionCoordinators.remove(id);
    }
}
Also used : SystemException(com.arjuna.wst.SystemException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) WrongStateException(com.arjuna.wst.WrongStateException) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) CompletionRPCStub(com.arjuna.wst11.stub.CompletionRPCStub) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) TxContextImple(com.arjuna.mwlabs.wst11.at.context.TxContextImple) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) CannotRegisterException(com.arjuna.wsc.CannotRegisterException) WrongStateException(com.arjuna.wst.WrongStateException) SystemException(com.arjuna.wst.SystemException) InvalidStateException(com.arjuna.wsc.InvalidStateException) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException)

Aggregations

SystemException (com.arjuna.wst.SystemException)74 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)63 WrongStateException (com.arjuna.wst.WrongStateException)45 TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)39 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)20 ArrayList (java.util.ArrayList)19 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)16 UserBusinessActivity (com.arjuna.mw.wst11.UserBusinessActivity)15 SoapFault (com.arjuna.webservices.SoapFault)15 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)13 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)11 TxContextImple (com.arjuna.mwlabs.wst11.ba.context.TxContextImple)11 MAP (org.jboss.ws.api.addressing.MAP)11 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)10 Context (com.arjuna.mw.wsc11.context.Context)6 FaultedException (com.arjuna.wst.FaultedException)6 BusinessActivityTerminator (com.arjuna.wst11.BusinessActivityTerminator)6 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)6 TxContext (com.arjuna.mw.wst.TxContext)5 BusinessActivityManager (com.arjuna.mw.wst11.BusinessActivityManager)5