Search in sources :

Example 26 with TransactionRolledBackException

use of com.arjuna.wst.TransactionRolledBackException 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)

Example 27 with TransactionRolledBackException

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

the class UserBusinessActivityStandaloneImple 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 terminatorCoordinatorRPC = getTerminationCoordinatorRPC(ctx);
        BusinessActivityTerminatorRPCStub terminatorRPCStub = new BusinessActivityTerminatorRPCStub(id, terminatorCoordinatorRPC);
        terminatorRPCStub.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 : BusinessActivityTerminatorRPCStub(com.arjuna.wst11.stub.BusinessActivityTerminatorRPCStub) 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) 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 28 with TransactionRolledBackException

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

the class ATTestCase method testAT4_2.

/**
 * testAT4_2 - 4.2 EarlyAborted
 * Tests the case of a participant initiated Aborted message occurring prior to the prepare phase.
 * @throws Exception on failure.
 */
public void testAT4_2() 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().earlyAborted(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)

Example 29 with TransactionRolledBackException

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

the class ATTestCase method testAT5_5.

/**
 * testAT5_5 - 5.5 PreparedAfterTimeout
 * Tests recovery from a communication failure during the prepare phase. Transaction times out. Two participants, volatile and durable.
 * @throws Exception on failure.
 */
public void testAT5_5() throws Exception {
    final String conversationId = getConversationId();
    final ATInteropPreparedAfterTimeoutState state = new ATInteropPreparedAfterTimeoutState();
    ProxyConversation.setConversationState(conversationId, state);
    try {
        final String serviceURI = ProxyURIRewriting.rewriteURI(conversationId, getParticipantURI());
        final CoordinationContextType context = ATInteropUtil.createCoordinationContext(getSourceCoordinatorURI());
        getParticipantStub().preparedAfterTimeout(serviceURI, context);
        final CompletionCoordinatorParticipant participant = ATInteropUtil.registerCompletion(context, context.getIdentifier().getValue());
        participant.commit();
        fail("Transaction rollback expected");
    } catch (final TransactionRolledBackException tre) {
        state.waitForCompletion(getTestTimeout());
    } finally {
        ProxyConversation.clearConversationState(conversationId);
    }
    assertTrue("Conversation did not complete successfully", state.isSuccessful());
}
Also used : ATInteropPreparedAfterTimeoutState(com.jboss.transaction.txinterop.interop.states.ATInteropPreparedAfterTimeoutState) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CompletionCoordinatorParticipant(com.arjuna.wst.CompletionCoordinatorParticipant)

Example 30 with TransactionRolledBackException

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

the class Sc007TestCase method test3_5.

/**
 * test3_5 - 3.5 EarlyAborted
 * Tests the case of a participant initiated Aborted message occurring prior to the prepare phase.
 * @throws Exception on failure.
 */
public void test3_5() 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 = InteropUtil.createCoordinationContext(getSourceCoordinatorURI());
        getParticipantStub().earlyAborted(serviceURI, context);
        final CompletionCoordinatorParticipant participant = InteropUtil.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.wstf.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