List of usage examples for javax.transaction TransactionRolledbackException TransactionRolledbackException
public TransactionRolledbackException(String msg)
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 {/* w w w.j a v a 2 s . c o 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(); } } }