Search in sources :

Example 1 with TransactionRolledBackException

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

the class UserTransactionImple 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();
        CompletionStub completionStub = new CompletionStub(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 : CompletionStub(com.arjuna.wst11.stub.CompletionStub) SystemException(com.arjuna.wst.SystemException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) WrongStateException(com.arjuna.wst.WrongStateException) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) TxContextImple(com.arjuna.mwlabs.wst11.at.context.TxContextImple) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) WrongStateException(com.arjuna.wst.WrongStateException) SystemException(com.arjuna.wst.SystemException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException)

Example 2 with TransactionRolledBackException

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

the class BusinessActivityTerminatorImple method close.

public void close() throws TransactionRolledBackException, UnknownTransactionException, SystemException {
    try {
        if (_hier == null)
            throw new UnknownTransactionException();
        _coordManager.resume(_hier);
        _coordManager.close();
    } catch (com.arjuna.mw.wsas.exceptions.InvalidActivityException ex) {
        throw new UnknownTransactionException();
    } catch (com.arjuna.mw.wsas.exceptions.ProtocolViolationException ex) {
        throw new SystemException(ex.toString());
    } catch (com.arjuna.mw.wscf.model.sagas.exceptions.CoordinatorCancelledException ex) {
        wstxLogger.i18NLogger.warn_mwlabs_wst11_ba_coordinator_cancelled_activity();
        throw new TransactionRolledBackException();
    } catch (com.arjuna.mw.wscf.exceptions.NoCoordinatorException ex) {
        throw new UnknownTransactionException();
    } catch (com.arjuna.mw.wsas.exceptions.WrongStateException ex) {
        throw new SystemException(ex.toString());
    } catch (com.arjuna.mw.wsas.exceptions.NoPermissionException ex) {
        throw new SystemException(ex.toString());
    } catch (com.arjuna.mw.wsas.exceptions.SystemException ex) {
        throw new SystemException(ex.toString());
    } catch (UnknownTransactionException ex) {
        throw ex;
    } finally {
        TerminationCoordinatorProcessor.getProcessor().deactivateParticipant(this);
    }
}
Also used : UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException)

Example 3 with TransactionRolledBackException

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

the class UserBusinessActivityImple method close.

public void close() throws TransactionRolledBackException, UnknownTransactionException, SystemException, WrongStateException {
    TxContextImple ctx = null;
    try {
        ctx = (TxContextImple) _ctxManager.suspend();
        if (ctx == null) {
            throw new WrongStateException();
        }
        final String id = ctx.identifier();
        final W3CEndpointReference terminatorCoordinator = getTerminationCoordinator(ctx);
        BusinessActivityTerminatorStub terminatorStub = new BusinessActivityTerminatorStub(id, terminatorCoordinator);
        terminatorStub.close();
    } catch (SystemException ex) {
        throw ex;
    } catch (TransactionRolledBackException ex) {
        throw ex;
    } catch (WrongStateException ex) {
        throw ex;
    } catch (UnknownTransactionException ex) {
        throw ex;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new SystemException(ex.toString());
    } finally {
        tidyup();
    }
}
Also used : SystemException(com.arjuna.wst.SystemException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) WrongStateException(com.arjuna.wst.WrongStateException) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) TxContextImple(com.arjuna.mwlabs.wst11.ba.context.TxContextImple) BusinessActivityTerminatorStub(com.arjuna.wst11.stub.BusinessActivityTerminatorStub) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) WrongStateException(com.arjuna.wst.WrongStateException) SystemException(com.arjuna.wst.SystemException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException)

Example 4 with TransactionRolledBackException

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

the class CloseBeforeCompletedTest method test.

@Test
public void test() throws Exception {
    ParticipantCompletionCoordinatorCloseBeforeCompletedRules.setParticipantCount(1);
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
    BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
    com.arjuna.wst11.BAParticipantManager bpm = null;
    DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CLOSE, "1235");
    try {
        uba.begin();
        bpm = bam.enlistForBusinessAgreementWithParticipantCompletion(p, p.identifier());
        bpm.completed();
    } catch (Exception eouter) {
        try {
            uba.cancel();
        } catch (Exception einner) {
            einner.printStackTrace();
        }
        throw eouter;
    }
    boolean caughtTransactionRolledBackException = false;
    try {
        uba.close();
    } catch (TransactionRolledBackException e) {
        caughtTransactionRolledBackException = true;
    }
    assertTrue(caughtTransactionRolledBackException);
}
Also used : DemoBusinessParticipant(com.arjuna.wstx.tests.common.DemoBusinessParticipant) BusinessActivityManager(com.arjuna.mw.wst11.BusinessActivityManager) UserBusinessActivity(com.arjuna.mw.wst11.UserBusinessActivity) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) Test(org.junit.Test)

Example 5 with TransactionRolledBackException

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

the class ATTestCase method testAT3_1.

/**
 * testAT3_1 - 3.1 Phase2Rollback
 * Coordinator aborts the transaction due to an Aborted vote during the prepare phase.
 * @throws Exception on failure.
 */
public void testAT3_1() throws Exception {
    final String conversationId = getConversationId();
    final InteropWaitState state = new InteropWaitState(AtomicTransactionConstants.WSAT_ACTION_ABORTED, 2);
    ProxyConversation.setConversationState(conversationId, state);
    try {
        final String serviceURI = ProxyURIRewriting.rewriteURI(conversationId, getParticipantURI());
        final CoordinationContextType context = ATInteropUtil.createCoordinationContext(getSourceCoordinatorURI());
        getParticipantStub().phase2Rollback(serviceURI, context);
        final CompletionCoordinatorParticipant participant = ATInteropUtil.registerCompletion(context, context.getIdentifier().getValue());
        participant.commit();
        fail("Transaction rollback expected");
    } catch (final TransactionRolledBackException trbe) {
        state.waitForCompletion(0);
    } finally {
        ProxyConversation.clearConversationState(conversationId);
    }
    assertTrue("Conversation did not complete successfully", state.isSuccessful());
}
Also used : TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) InteropWaitState(com.jboss.transaction.txinterop.interop.states.InteropWaitState) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CompletionCoordinatorParticipant(com.arjuna.wst.CompletionCoordinatorParticipant)

Aggregations

TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)41 SystemException (com.arjuna.wst.SystemException)29 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)29 WrongStateException (com.arjuna.wst.WrongStateException)22 ArrayList (java.util.ArrayList)18 UserBusinessActivity (com.arjuna.mw.wst11.UserBusinessActivity)15 CompletionCoordinatorParticipant (com.arjuna.wst.CompletionCoordinatorParticipant)8 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)8 UserTransaction (com.arjuna.mw.wst11.UserTransaction)7 SoapFault (com.arjuna.webservices.SoapFault)5 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)5 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)5 MAP (org.jboss.ws.api.addressing.MAP)5 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)4 Test (org.junit.Test)3 TxContext (com.arjuna.mw.wst.TxContext)2 TransactionManager (com.arjuna.mw.wst11.TransactionManager)2 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)2 TxContextImple (com.arjuna.mwlabs.wst11.ba.context.TxContextImple)2 SoapFault11 (com.arjuna.webservices11.SoapFault11)2