List of usage examples for javax.ejb TransactionRolledbackLocalException TransactionRolledbackLocalException
public TransactionRolledbackLocalException()
From source file:org.openejb.transaction.TxRequired.java
public InvocationResult invoke(Interceptor interceptor, EjbInvocation ejbInvocation, TransactionManager transactionManager) throws Throwable { Transaction transaction = transactionManager.getTransaction(); if (transaction != null) { try {/*from w w w . j a v a 2 s .co m*/ return interceptor.invoke(ejbInvocation); } catch (Throwable t) { transactionManager.setRollbackOnly(); if (ejbInvocation.getType().isLocal()) { throw new TransactionRolledbackLocalException().initCause(t); } else { // can't set an initCause on a TransactionRolledbackException throw new TransactionRolledbackException(t.getMessage()); } } } transactionManager.begin(); try { InvocationResult result = interceptor.invoke(ejbInvocation); return result; } catch (RollbackException re) { throw re; } catch (Throwable t) { try { transactionManager.setRollbackOnly(); } catch (Exception e) { log.warn("Unable to roll back", e); } throw t; } finally { if (transactionManager.getStatus() == Status.STATUS_ACTIVE) { transactionManager.commit(); } else { transactionManager.rollback(); } } }