Search in sources :

Example 6 with NotSupportedException

use of javax.transaction.NotSupportedException in project carbon-business-process by wso2.

the class TransactionManagerProvider method doNonTransactionalWork.

public void doNonTransactionalWork(Runnable runnable) throws NotSupportedException {
    TransactionManager tm;
    Transaction transaction;
    try {
        tm = getTransactionManager();
        transaction = tm.suspend();
    } catch (Exception e) {
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
    runnable.run();
    try {
        tm.resume(transaction);
    } catch (Exception e) {
        try {
            transaction.setRollbackOnly();
        } catch (SystemException se2) {
            throw new GeneralException(se2);
        }
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
}
Also used : GeneralException(org.apache.openjpa.util.GeneralException) Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager) NotSupportedException(javax.transaction.NotSupportedException) GeneralException(org.apache.openjpa.util.GeneralException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException)

Example 7 with NotSupportedException

use of javax.transaction.NotSupportedException in project carbon-business-process by wso2.

the class TransactionManagerProvider method doNonTransactionalWork.

public void doNonTransactionalWork(java.lang.Runnable runnable) throws NotSupportedException {
    TransactionManager transactionManager = null;
    Transaction transaction = null;
    try {
        transactionManager = getTransactionManager();
        transaction = transactionManager.suspend();
    } catch (Exception e) {
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        log.error(nse.getLocalizedMessage(), nse);
        throw nse;
    }
    runnable.run();
    try {
        transactionManager.resume(transaction);
    } catch (Exception e) {
        log.error(e.getLocalizedMessage(), e);
        try {
            transaction.setRollbackOnly();
        } catch (SystemException se2) {
            throw new GeneralException(se2);
        }
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
}
Also used : GeneralException(org.apache.openjpa.util.GeneralException) Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager) NotSupportedException(javax.transaction.NotSupportedException) GeneralException(org.apache.openjpa.util.GeneralException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException)

Example 8 with NotSupportedException

use of javax.transaction.NotSupportedException in project narayana by jbosstm.

the class Test02 method main.

public static void main(String[] args) {
    Setup orbClass = null;
    try {
        boolean needOrb = true;
        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("-local")) {
                needOrb = false;
            }
        }
        if (needOrb) {
            Class c = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.jbossts.qa.Utils.OrbSetup");
            orbClass = (Setup) c.newInstance();
            orbClass.start(args);
        }
        boolean correct = true;
        javax.transaction.TransactionManager transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
        correct = correct && (transactionManager.getTransaction() == null);
        correct = correct && (transactionManager.getStatus() == Status.STATUS_NO_TRANSACTION);
        transactionManager.begin();
        correct = correct && (transactionManager.getTransaction() != null);
        correct = correct && (transactionManager.getStatus() == Status.STATUS_ACTIVE);
        try {
            transactionManager.begin();
            correct = false;
        } catch (NotSupportedException notSupportedException) {
        }
        correct = correct && (transactionManager.getTransaction() != null);
        correct = correct && (transactionManager.getStatus() == Status.STATUS_ACTIVE);
        transactionManager.commit();
        correct = correct && (transactionManager.getTransaction() == null);
        correct = correct && (transactionManager.getStatus() == Status.STATUS_NO_TRANSACTION);
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.print("Test02.main: ");
        exception.printStackTrace(System.err);
    } catch (Error error) {
        System.out.println("Failed");
        System.err.print("Test02.main: ");
        error.printStackTrace(System.err);
    }
    try {
        if (orbClass != null) {
            orbClass.stop();
        }
    } catch (Exception exception) {
        System.err.print("Test02.main: ");
        exception.printStackTrace(System.err);
    } catch (Error error) {
        System.err.print("Test02.main: ");
        error.printStackTrace(System.err);
    }
}
Also used : Setup(org.jboss.jbossts.qa.Utils.Setup) NotSupportedException(javax.transaction.NotSupportedException) NotSupportedException(javax.transaction.NotSupportedException)

Example 9 with NotSupportedException

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

the class FastLocalCacheProvider method createFile.

@Deprecated
@Override
public void createFile(ConcreteResource resource) throws IOException {
    final String pathKey = getKeyForResource(resource);
    try {
        lockByISPN(nfsOwnerCache, resource, LockLevel.write);
        final File nfsFile = getNFSDetachedFile(resource);
        if (!nfsFile.exists()) {
            nfsFile.getParentFile().mkdirs();
            nfsFile.createNewFile();
        }
    } catch (NotSupportedException | SystemException | InterruptedException e) {
        final String errorMsg = String.format("[galley] Cache TransactionManager got error, locking key is %s", pathKey);
        logger.error(errorMsg, e);
        throw new IllegalStateException(errorMsg, e);
    } finally {
        unlockByISPN(nfsOwnerCache, false, resource);
    }
}
Also used : SystemException(javax.transaction.SystemException) NotSupportedException(javax.transaction.NotSupportedException) File(java.io.File)

Example 10 with NotSupportedException

use of javax.transaction.NotSupportedException in project narayana by jbosstm.

the class UserTransactionUnitTest method testSubordinate.

@Test
public void testSubordinate() throws Exception {
    ThreadActionData.purgeActions();
    UserTransactionImple ut = new UserTransactionImple();
    assertTrue(ut.createSubordinate() != null);
    ut.begin();
    try {
        ut.createSubordinate();
        fail();
    } catch (final NotSupportedException ex) {
    }
    ut.commit();
}
Also used : UserTransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple) NotSupportedException(javax.transaction.NotSupportedException) Test(org.junit.Test)

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