Package org.apache.openejb

Examples of org.apache.openejb.SystemException


        boolean shouldRollback;
        try {
            shouldRollback = tx.getStatus() != Status.STATUS_ACTIVE;
        } catch (javax.transaction.SystemException e) {
            txLogger.error("The Transaction Manager has encountered an unexpected error condition while attempting to obtain transaction status: {0}", e.getMessage());
            throw new SystemException(e);
        }

        if (shouldRollback) {
            rollbackTransaction(tx);
            return;
        }

        try {
            txLogger.debug("TX {0}: Committing transaction {1}", transactionType, tx);
            if (tx.equals(transactionManager.getTransaction())) {

                transactionManager.commit();
            } else {
                tx.commit();
            }
        } catch (RollbackException e) {

            txLogger.debug("The transaction has been rolled back rather than commited: {0}", e.getMessage());
            Throwable txe = new TransactionRolledbackException("Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization").initCause(e);
            throw new ApplicationException(txe);

        } catch (HeuristicMixedException e) {

            txLogger.debug("A heuristic decision was made, some relevant updates have been committed while others have been rolled back: {0}", e.getMessage());
            throw new ApplicationException(new RemoteException("A heuristic decision was made, some relevant updates have been committed while others have been rolled back", e));

        } catch (HeuristicRollbackException e) {

            txLogger.debug("A heuristic decision was made while commiting the transaction, some relevant updates have been rolled back: {0}", e.getMessage());
            throw new ApplicationException(new RemoteException("A heuristic decision was made while commiting the transaction, some relevant updates have been rolled back", e));

        } catch (SecurityException e) {

            txLogger.error("The current thread is not allowed to commit the transaction: {0}", e.getMessage());
            throw new SystemException(e);

        } catch (IllegalStateException e) {

            txLogger.error("The current thread is not associated with a transaction: {0}", e.getMessage());
            throw new SystemException(e);

        } catch (javax.transaction.SystemException e) {
            txLogger.error("The Transaction Manager has encountered an unexpected error condition while attempting to commit the transaction: {0}", e.getMessage());

            throw new SystemException(e);
        }
    }
View Full Code Here


                tx.rollback();
            }
        } catch (IllegalStateException e) {

            logger.error("The TransactionManager reported an exception while attempting to rollback the transaction: " + e.getMessage());
            throw new SystemException(e);

        } catch (javax.transaction.SystemException e) {

            logger.error("The TransactionManager reported an exception while attempting to rollback the transaction: " + e.getMessage());
            throw new SystemException(e);
        }
    }
View Full Code Here

    public void resumeUserTransaction(SuspendedTransaction suspendedTransaction) throws SystemException {
        if (suspendedTransaction == null) throw new NullPointerException("suspendedTransaction is null");
       
        Transaction beanTransaction = ((JtaSuspendedTransaction) suspendedTransaction).transaction;
        if (beanTransaction == null) {
            throw new SystemException("Bean transaction has already been resumed or destroyed");
        }

        try {
            resumeTransaction(beanTransaction);
        } catch (SystemException e) {
View Full Code Here

        return instance;
    }

    private Instance obtainInstance(Object primaryKey, ThreadContext callContext) throws OpenEJBException {
        if (primaryKey == null) {
            throw new SystemException(new NullPointerException("Cannot obtain an instance of the stateful session bean with a null session id"));
        }

        Transaction currentTransaction = getTransaction(callContext);

        // Find the instance
        Instance instance = checkedOutInstances.get(primaryKey);
        if (instance == null) {
            try {
                instance = cache.checkOut(primaryKey);
            } catch (OpenEJBException e) {
                throw e;
            } catch (Exception e) {
                throw new SystemException("Unexpected load exception", e);
            }

            // Did we find the instance?
            if (instance == null) {
                throw new InvalidateReferenceException(new NoSuchObjectException("Not Found"));
View Full Code Here

                /* [3] Throw the RemoteException to the client */
                throwAppExceptionToServer(new RemoteException(message));
            }

        } catch (javax.transaction.SystemException e) {
            throw new SystemException(e);
        } finally {
            resumeTransaction(context, context.clientTx);
        }
    }
View Full Code Here

        return new StatelessContext(transactionManager, securityService);
    }

    public void poolInstance(ThreadContext callContext, Object bean) throws OpenEJBException {
        if (bean == null) {
            throw new SystemException("Invalid arguments");
        }

        CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
        Data data = (Data) deploymentInfo.getContainerData();
        Stack pool = data.getPool();
View Full Code Here

                /* [3] Throw the RemoteException to the client */
                throwAppExceptionToServer(new RemoteException(message));
            }

        } catch (javax.transaction.SystemException e) {
            throw new SystemException(e);
        } finally {
            resumeTransaction(context, context.clientTx);
        }
    }
View Full Code Here

        return new StatefulContext(transactionManager, securityService, userTransaction);
    }

    public Object obtainInstance(Object primaryKey, ThreadContext callContext) throws OpenEJBException {
        if (primaryKey == null) {
            throw new SystemException(new NullPointerException("Cannot obtain an instance of the stateful session bean with a null session id"));
        }

        // look for entry in index
        BeanEntry entry = getBeanIndex(callContext).get(primaryKey);
View Full Code Here

    }

    public void poolInstance(ThreadContext callContext, Object bean) throws OpenEJBException {
        Object primaryKey = callContext.getPrimaryKey();
        if (primaryKey == null || bean == null) {
            throw new SystemException("Invalid arguments");
        }

        BeanEntry entry = getBeanIndex(callContext).get(primaryKey);
        if (entry == null) {
            entry = activate(primaryKey);
            if (entry == null) {
                throw new SystemException("Invalid primaryKey:" + primaryKey);
            }
        } else if (entry.bean != bean) {
            throw new SystemException("Invalid ID for bean");
        }

        if (entry.beanTransaction == null) {
            if (callContext.getCurrentOperation() != Operation.CREATE){
                try {
                    entry.beanTransaction = transactionManager.getTransaction();
                } catch (javax.transaction.SystemException se) {
                    throw new SystemException("TransactionManager failure", se);
                }
            }

            // only put in LRU if no current transaction
            if (entry.beanTransaction == null) {
View Full Code Here

        lruQueue.remove(entry);// remove from queue
        if (entry.beanTransaction != null) {
            try {
                entry.beanTransaction.setRollbackOnly();
            } catch (javax.transaction.SystemException se) {
                throw new SystemException(se);
            } catch (IllegalStateException ise) {
                throw new SystemException("Attempt to rollback a non-tx context", ise);
            } catch (SecurityException lse) {
                throw new SystemException("Container not authorized to rollback tx", lse);
            }
            return new InvalidateReferenceException(new TransactionRolledbackException(t));
        } else if (t instanceof RemoteException) {
            return new InvalidateReferenceException(t);
        } else {
View Full Code Here

TOP

Related Classes of org.apache.openejb.SystemException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.