Search in sources :

Example 26 with NotSupportedException

use of javax.transaction.NotSupportedException in project aries by apache.

the class TranStrategyTest method testRequiresNew_TmExceptions.

@Test
public void testRequiresNew_TmExceptions() throws Exception {
    int[] allStates = new int[] { Status.STATUS_COMMITTED, Status.STATUS_COMMITTING, Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_PREPARED, Status.STATUS_PREPARING, Status.STATUS_ROLLEDBACK, Status.STATUS_MARKED_ROLLBACK, Status.STATUS_ROLLING_BACK, Status.STATUS_UNKNOWN };
    // SystemException and NotSupportedException from tm.begin()
    Set<Exception> ees = new HashSet<Exception>();
    ees.add(new SystemException("KABOOM!"));
    ees.add(new NotSupportedException("KABOOM!"));
    // from tm.begin()
    for (int i = 0; i < allStates.length; i++) {
        Iterator<Exception> iterator = ees.iterator();
        while (iterator.hasNext()) {
            Exception e = iterator.next();
            c.reset();
            expect(tm.getStatus()).andReturn(allStates[i]);
            expect(tm.getTransaction()).andReturn(null).anyTimes();
            tm.begin();
            expectLastCall().andThrow(e);
            requiresNewExceptionCheck(tm, allStates[i]);
        }
    }
}
Also used : SystemException(javax.transaction.SystemException) NotSupportedException(javax.transaction.NotSupportedException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with NotSupportedException

use of javax.transaction.NotSupportedException in project meecrowave by apache.

the class RequiredInterceptor method start.

@Override
protected State start() {
    try {
        final Transaction transaction = transactionManager.getTransaction();
        final Transaction current;
        if (transaction == null) {
            transactionManager.begin();
            current = transactionManager.getTransaction();
        } else {
            current = transaction;
        }
        return new State(transaction, current);
    } catch (final SystemException | NotSupportedException se) {
        throw new TransactionalException(se.getMessage(), se);
    }
}
Also used : Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) TransactionalException(javax.transaction.TransactionalException) NotSupportedException(javax.transaction.NotSupportedException)

Example 28 with NotSupportedException

use of javax.transaction.NotSupportedException in project meecrowave by apache.

the class RequiredNewInterceptor method start.

@Override
protected State start() {
    try {
        final Transaction transaction = transactionManager.suspend();
        transactionManager.begin();
        return new State(transaction, transactionManager.getTransaction());
    } catch (final SystemException | NotSupportedException se) {
        throw new TransactionalException(se.getMessage(), se);
    }
}
Also used : Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) TransactionalException(javax.transaction.TransactionalException) NotSupportedException(javax.transaction.NotSupportedException)

Example 29 with NotSupportedException

use of javax.transaction.NotSupportedException in project smscgateway by RestComm.

the class SchedulerResourceAdaptor method doInjectSms.

private boolean doInjectSms(SmsSet smsSet, boolean callFromSbb) throws NotSupportedException, SystemException, Exception, RollbackException, HeuristicMixedException, HeuristicRollbackException {
    if (!callFromSbb) {
        // If this call is from SBB it comes with Transaction and no need to start one
        SleeTransaction sleeTx = this.sleeTransactionManager.beginSleeTransaction();
    }
    try {
        this.doSetDestCluster(smsSet);
        String eventName = null;
        switch(smsSet.getType()) {
            case SMS_FOR_ESME:
                eventName = EVENT_SMPP_SM;
                break;
            case SMS_FOR_SS7:
                eventName = EVENT_SS7_SM;
                break;
            case SMS_FOR_SIP:
                eventName = EVENT_SIP_SM;
                break;
        }
        final FireableEventType eventTypeId = this.eventIdCache.getEventId(eventName);
        SmsSetEvent event = new SmsSetEvent();
        event.setSmsSet(smsSet);
        SchedulerActivityImpl activity = new SchedulerActivityImpl(this);
        this.sleeEndpoint.startActivityTransacted(activity.getActivityHandle(), activity, ACTIVITY_FLAGS);
        try {
            this.sleeEndpoint.fireEventTransacted(activity.getActivityHandle(), eventTypeId, event, null, null);
        } catch (Exception e) {
            if (this.tracer.isSevereEnabled()) {
                this.tracer.severe("Failed to fire SmsSet event Class=: " + eventTypeId.getEventClassName(), e);
            }
            try {
                this.sleeEndpoint.endActivityTransacted(activity.getActivityHandle());
            } catch (Exception ee) {
            }
        }
        markAsInSystem(smsSet);
    } catch (Exception e) {
        if (!callFromSbb) {
            this.sleeTransactionManager.rollback();
        }
        throw e;
    }
    if (!callFromSbb) {
        // If this call is from SBB it comes with Transaction and no need to commit here
        this.sleeTransactionManager.commit();
    }
    this.incrementActivityCount();
    return true;
}
Also used : SleeTransaction(javax.slee.transaction.SleeTransaction) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) FireableEventType(javax.slee.resource.FireableEventType) RollbackException(javax.transaction.RollbackException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) HeuristicRollbackException(javax.transaction.HeuristicRollbackException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) HeuristicMixedException(javax.transaction.HeuristicMixedException)

Example 30 with NotSupportedException

use of javax.transaction.NotSupportedException in project partyline by Commonjava.

the class InfinispanJFS method updateBlock.

void updateBlock(final FileBlock block) throws IOException {
    TransactionManager transactionManager = blockCache.getAdvancedCache().getTransactionManager();
    try {
        transactionManager.begin();
        blockCache.put(block.getBlockID(), block);
    } catch (NotSupportedException | SystemException e) {
        try {
            transactionManager.rollback();
            throw new PartylineException("Failed to begin transaction. Rolling back. Block: " + block.getBlockID(), e);
        } catch (SystemException e1) {
            LoggerFactory.getLogger(getClass().getName()).error("System Exception during transaction rollback involving Block: " + block.getBlockID(), e1);
        }
    } finally {
        try {
            transactionManager.commit();
        } catch (RollbackException | HeuristicMixedException | HeuristicRollbackException | SystemException e) {
            LoggerFactory.getLogger(getClass().getName()).error("Exception during transaction commit involving block: " + block.getBlockID(), e);
        }
    }
}
Also used : HeuristicRollbackException(javax.transaction.HeuristicRollbackException) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager) HeuristicMixedException(javax.transaction.HeuristicMixedException) PartylineException(org.commonjava.util.partyline.PartylineException) NotSupportedException(javax.transaction.NotSupportedException) RollbackException(javax.transaction.RollbackException) HeuristicRollbackException(javax.transaction.HeuristicRollbackException)

Aggregations

NotSupportedException (javax.transaction.NotSupportedException)53 SystemException (javax.transaction.SystemException)42 RollbackException (javax.transaction.RollbackException)22 HeuristicMixedException (javax.transaction.HeuristicMixedException)20 HeuristicRollbackException (javax.transaction.HeuristicRollbackException)20 Transaction (javax.transaction.Transaction)17 UserTransaction (javax.transaction.UserTransaction)11 TransactionManager (javax.transaction.TransactionManager)10 SQLException (java.sql.SQLException)8 NamingException (javax.naming.NamingException)7 IOException (java.io.IOException)6 Test (org.junit.Test)6 InvalidTransactionException (javax.transaction.InvalidTransactionException)5 Connection (java.sql.Connection)4 GeneralException (org.apache.openjpa.util.GeneralException)4 File (java.io.File)3 NucleusDataStoreException (org.datanucleus.exceptions.NucleusDataStoreException)3 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 InputStream (java.io.InputStream)2