Search in sources :

Example 21 with NotSupportedException

use of javax.transaction.NotSupportedException in project neo4j-mobile-android by neo4j-contrib.

the class TxManager method begin.

public void begin() throws NotSupportedException, SystemException {
    if (blocked) {
        throw new SystemException("TxManager is preventing new transactions from starting " + "due a shutdown is imminent");
    }
    assertTmOk("tx begin");
    Thread thread = Thread.currentThread();
    TransactionImpl tx = txThreadMap.get(thread);
    if (tx != null) {
        throw logAndReturn("TM error tx begin", new NotSupportedException("Nested transactions not supported"));
    }
    tx = new TransactionImpl(this);
    txThreadMap.put(thread, tx);
    int concurrentTxCount = txThreadMap.size();
    if (concurrentTxCount > peakConcurrentTransactions) {
        peakConcurrentTransactions = concurrentTxCount;
    }
    startedTxCount.incrementAndGet();
// start record written on resource enlistment
}
Also used : SystemException(javax.transaction.SystemException) NotSupportedException(javax.transaction.NotSupportedException)

Example 22 with NotSupportedException

use of javax.transaction.NotSupportedException in project wildfly by wildfly.

the class TransactionalBatcher method createBatch.

@Override
public TransactionBatch createBatch() {
    if (this.tm == null)
        return NON_TX_BATCH;
    TransactionBatch batch = getCurrentBatch();
    try {
        if ((batch != null) && (batch.getState() == Batch.State.ACTIVE)) {
            return batch.interpose();
        }
        this.tm.suspend();
        this.tm.begin();
        Transaction tx = this.tm.getTransaction();
        tx.registerSynchronization(CURRENT_BATCH_SYNCHRONIZATION);
        batch = new TransactionalBatch<>(tx, this.exceptionTransformer);
        setCurrentBatch(batch);
        return batch;
    } catch (RollbackException | SystemException | NotSupportedException e) {
        throw this.exceptionTransformer.apply(e);
    }
}
Also used : Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) RollbackException(javax.transaction.RollbackException) NotSupportedException(javax.transaction.NotSupportedException)

Example 23 with NotSupportedException

use of javax.transaction.NotSupportedException in project wildfly by wildfly.

the class BMTStateful method createTransaction.

public void createTransaction() {
    try {
        final UserTransaction userTransaction = ejbContext.getUserTransaction();
        Assert.assertEquals(Status.STATUS_NO_TRANSACTION, userTransaction.getStatus());
        userTransaction.begin();
    } catch (SystemException e) {
        throw new RuntimeException(e);
    } catch (NotSupportedException e) {
        throw new RuntimeException(e);
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) SystemException(javax.transaction.SystemException) NotSupportedException(javax.transaction.NotSupportedException)

Example 24 with NotSupportedException

use of javax.transaction.NotSupportedException in project wildfly by wildfly.

the class TestEJBRunnable method run.

@Override
public void run() {
    // asserts correct class loader is set
    try {
        Thread.currentThread().getContextClassLoader().loadClass(this.getClass().getName());
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
    // asserts correct naming context is set
    final InitialContext initialContext;
    try {
        initialContext = new InitialContext();
    } catch (NamingException e) {
        throw new RuntimeException(e);
    }
    final EJBContext ejbContext;
    try {
        ejbContext = (SessionContext) initialContext.lookup("java:comp/EJBContext");
    } catch (NamingException e) {
        throw new RuntimeException(e);
    }
    // asserts correct security context is set
    final Principal callerPrincipal = ejbContext.getCallerPrincipal();
    if (expectedPrincipal != null) {
        if (!expectedPrincipal.equals(callerPrincipal)) {
            throw new IllegalStateException("the caller principal " + callerPrincipal + " is not the expected " + expectedPrincipal);
        }
    } else {
        if (callerPrincipal != null) {
            throw new IllegalStateException("the caller principal " + callerPrincipal + " is not the expected " + expectedPrincipal);
        }
    }
    // assert tx context is set
    try {
        final UserTransaction userTransaction = (UserTransaction) initialContext.lookup("java:comp/UserTransaction");
        userTransaction.begin();
        userTransaction.rollback();
    } catch (NamingException | SystemException | NotSupportedException e) {
        throw new RuntimeException(e);
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) EJBContext(javax.ejb.EJBContext) SystemException(javax.transaction.SystemException) NamingException(javax.naming.NamingException) NotSupportedException(javax.transaction.NotSupportedException) InitialContext(javax.naming.InitialContext) Principal(java.security.Principal)

Example 25 with NotSupportedException

use of javax.transaction.NotSupportedException in project graphdb by neo4j-attic.

the class MasterImpl method beginTx.

private Transaction beginTx(SlaveContext txId) {
    try {
        TransactionManager txManager = graphDbConfig.getTxModule().getTxManager();
        txManager.begin();
        Transaction tx = txManager.getTransaction();
        transactions.put(txId, tx);
        return tx;
    } catch (NotSupportedException e) {
        throw new RuntimeException(e);
    } catch (SystemException e) {
        throw new RuntimeException(e);
    }
}
Also used : Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager) NotSupportedException(javax.transaction.NotSupportedException)

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