javax.transaction.RollbackException Java Examples

The following examples show how to use javax.transaction.RollbackException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TxConnectionManagerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets time left.
 * @param errorRollback error rollback
 * @return time left in ms
 * @throws RollbackException if exception
 */
public long getTimeLeftBeforeTransactionTimeout(boolean errorRollback) throws RollbackException
{
   if (transactionManager == null)
   {
      throw new IllegalStateException("No transaction manager: " + getCachedConnectionManager());  
   }

   if (transactionManager instanceof TransactionTimeoutConfiguration)
   {
      return ((TransactionTimeoutConfiguration)transactionManager).
         getTimeLeftBeforeTransactionTimeout(errorRollback);  
   }

   if (transactionManager instanceof ContextTransactionManager)
   {
      AbstractTransaction transaction = ((ContextTransactionManager) transactionManager).getTransaction();
      if (transaction != null) {
         return transaction.getEstimatedRemainingTime() * 1000;
      }
   }

   return -1;
}
 
Example #2
Source File: CompensableManagerImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void invokeTransactionCommitIfNotLocalTransaction(CompensableTransaction compensable) throws RollbackException,
		HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {

	Transaction transaction = compensable.getTransaction();
	org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext();
	TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant();

	TransactionXid transactionXid = transactionContext.getXid();
	try {
		transactionCoordinator.end(transactionContext, XAResource.TMSUCCESS);

		TransactionContext compensableContext = compensable.getTransactionContext();
		logger.error("{}> jta-transaction in try-phase cannot be xa transaction.",
				ByteUtils.byteArrayToString(compensableContext.getXid().getGlobalTransactionId()));

		transactionCoordinator.rollback(transactionXid);
		throw new HeuristicRollbackException();
	} catch (XAException xaEx) {
		transactionCoordinator.forgetQuietly(transactionXid);
		SystemException sysEx = new SystemException(xaEx.errorCode);
		sysEx.initCause(xaEx);
		throw sysEx;
	}
}
 
Example #3
Source File: TradeSLSBBean.java    From jboss-daytrader with Apache License 2.0 6 votes vote down vote up
public AccountDataBean login(String userID, String password) throws RollbackException {
    AccountProfileDataBean profile = entityManager.find(AccountProfileDataBean.class, userID);

    if (profile == null) {
        throw new EJBException("No such user: " + userID);
    }
    entityManager.merge(profile);
    AccountDataBean account = profile.getAccount();

    if (Log.doTrace())
        Log.trace("TradeSLSBBean:login", userID, password);
    account.login(password);
    if (Log.doTrace())
        Log.trace("TradeSLSBBean:login(" + userID + "," + password + ") success" + account);

    return account;
}
 
Example #4
Source File: JPAResource.java    From boost with Eclipse Public License 1.0 6 votes vote down vote up
public void createThing(StringBuilder builder)
        throws NamingException, NotSupportedException, SystemException, IllegalStateException, SecurityException,
        HeuristicMixedException, HeuristicRollbackException, RollbackException {
    Context ctx = new InitialContext();
    // Before getting an EntityManager, start a global transaction
    UserTransaction tran = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
    tran.begin();

    // Now get the EntityManager from JNDI
    EntityManager em = (EntityManager) ctx.lookup(JNDI_NAME);
    builder.append("Creating a brand new Thing with " + em.getDelegate().getClass()).append(newline);

    // Create a Thing object and persist it to the database
    Thing thing = new Thing();
    em.persist(thing);

    // Commit the transaction
    tran.commit();
    int id = thing.getId();
    builder.append("Created Thing " + id + ":  " + thing).append(newline);
}
 
Example #5
Source File: ServiceSynchronization.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
protected static ServiceSynchronization getInstance() throws GenericServiceException {
    ServiceSynchronization sync = null;
    try {
        Transaction transaction = TransactionFactoryLoader.getInstance().getTransactionManager().getTransaction();
        synchronized (transaction) {
            sync = syncingleton.get(transaction);
            if (sync == null) {
                sync = new ServiceSynchronization();
                transaction.registerSynchronization(sync);
                syncingleton.put(transaction, sync);
            }
        }
    } catch (SystemException | IllegalStateException | RollbackException e) {
        throw new GenericServiceException(e.getMessage(), e);
    }
    return sync;
}
 
Example #6
Source File: PseudoTransactionService.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void commit() throws RollbackException {
    try {
        if (status == Status.STATUS_MARKED_ROLLBACK) {
            rollback();
            throw new RollbackException();
        }
        try {
            doBeforeCompletion();
        } catch (final Exception e) {
            rollback();
            throw (RollbackException) new RollbackException().initCause(e);
        }
        doXAResources(Status.STATUS_COMMITTED);
        status = Status.STATUS_COMMITTED;
        doAfterCompletion(Status.STATUS_COMMITTED);
    } finally {
        threadTransaction.set(null);
    }
}
 
Example #7
Source File: TransactionManagerImpl.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void commit() throws RollbackException,
                            HeuristicMixedException,
                            HeuristicRollbackException,
                            SecurityException,
                            IllegalStateException,
                            SystemException
{
   Transaction tx = registry.getTransaction();

   if (tx == null)
      throw new SystemException();

   if (tx.getStatus() == Status.STATUS_ROLLEDBACK ||
       tx.getStatus() == Status.STATUS_MARKED_ROLLBACK)
      throw new RollbackException();

   registry.commitTransaction();
}
 
Example #8
Source File: DefaultTransaction.java    From piranha with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Commit the transaction.
 *
 * @throws RollbackException when a rollback error occurs.
 * @throws HeuristicMixedException when the heuristics were mixed.
 * @throws HeuristicRollbackException when a rollback error occurs.
 * @throws SecurityException when a security error occurs.
 * @throws IllegalStateException when the transaction is not active.
 * @throws SystemException when a serious error occurs.
 */
@Override
public synchronized void commit() throws RollbackException, HeuristicMixedException,
        HeuristicRollbackException, SecurityException,
        IllegalStateException, SystemException {
    handleBeforeCompletion();
    try {
        switch (status) {
            case Status.STATUS_COMMITTED:
                break;
            case Status.STATUS_MARKED_ROLLBACK: {
                rollback();
                throw new HeuristicRollbackException();
            }
            case Status.STATUS_ROLLEDBACK: {
                throw new RollbackException();
            }
            default: {
                status = Status.STATUS_COMMITTED;
            }
        }
    } finally {
        handleAfterCompletion();
    }
}
 
Example #9
Source File: SimpleTransaction.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
        SecurityException, SystemException
{
    try
    {
        if (isRollBackOnly)
        {
            throw new RollbackException("Commit failed: Transaction marked for rollback");
        }

    }
    finally
    {
        transaction.set(null);
    }
}
 
Example #10
Source File: PeopleTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void createUsers() throws HeuristicRollbackException, RollbackException, HeuristicMixedException, SystemException, NotSupportedException
    {
        txn = transactionService.getUserTransaction();
        txn.begin();
        for (UserInfo user : userInfos)
        {
            String username = user.getUserName();
            NodeRef nodeRef = personService.getPersonOrNull(username);
            boolean create = nodeRef == null;
            if (create)
            {
                PropertyMap testUser = new PropertyMap();
                testUser.put(ContentModel.PROP_USERNAME, username);
                testUser.put(ContentModel.PROP_FIRSTNAME, user.getFirstName());
                testUser.put(ContentModel.PROP_LASTNAME, user.getLastName());
                testUser.put(ContentModel.PROP_EMAIL, user.getUserName() + "@acme.test");
                testUser.put(ContentModel.PROP_PASSWORD, "password");

                nodeRef = personService.createPerson(testUser);
            }
            userNodeRefs.add(nodeRef);
//            System.out.println((create ? "create" : "existing")+" user " + username + " nodeRef=" + nodeRef);
        }
        txn.commit();
    }
 
Example #11
Source File: TransactionImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 6 votes vote down vote up
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
		SecurityException, IllegalStateException, CommitRequiredException, SystemException {

	if (this.transactionStatus == Status.STATUS_ACTIVE) {
		this.fireCommit();
	} else if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) {
		this.fireRollback();
		throw new HeuristicRollbackException();
	} else if (this.transactionStatus == Status.STATUS_ROLLEDBACK) /* should never happen */ {
		throw new RollbackException();
	} else if (this.transactionStatus == Status.STATUS_COMMITTED) /* should never happen */ {
		logger.debug("Current transaction has already been committed.");
	} else {
		throw new IllegalStateException();
	}

}
 
Example #12
Source File: SpringAwareUserTransactionTest.java    From alfresco-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testPostSetRollbackOnlyCommitDetection() throws Exception
{
    testNoTxnStatus();

    txn.begin();
    txn.setRollbackOnly();
    try
    {
        txn.commit();
        fail("Failed to detect set rollback");
    }
    catch (RollbackException e)
    {
        // expected
        txn.rollback();
    }
    checkNoStatusOnThread();
}
 
Example #13
Source File: JPAResource.java    From microprofile-sandbox with Apache License 2.0 6 votes vote down vote up
public void createThing(StringBuilder builder)
        throws NamingException, NotSupportedException, SystemException, IllegalStateException, SecurityException,
        HeuristicMixedException, HeuristicRollbackException, RollbackException {
    Context ctx = new InitialContext();
    // Before getting an EntityManager, start a global transaction
    UserTransaction tran = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
    tran.begin();

    // Now get the EntityManager from JNDI
    EntityManager em = (EntityManager) ctx.lookup(JNDI_NAME);
    builder.append("Creating a brand new Thing with " + em.getDelegate().getClass()).append(newline);

    // Create a Thing object and persist it to the database
    Thing thing = new Thing();
    em.persist(thing);

    // Commit the transaction
    tran.commit();
    int id = thing.getId();
    builder.append("Created Thing " + id + ":  " + thing).append(newline);
}
 
Example #14
Source File: CompensableTransactionImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 6 votes vote down vote up
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
		SecurityException, IllegalStateException, SystemException {

	if (this.transactionStatus == Status.STATUS_ACTIVE) {
		this.fireCommit();
	} else if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) {
		this.fireRollback();
		throw new HeuristicRollbackException();
	} else if (this.transactionStatus == Status.STATUS_ROLLEDBACK) /* should never happen */ {
		throw new RollbackException();
	} else if (this.transactionStatus == Status.STATUS_COMMITTED) /* should never happen */ {
		logger.debug("Current transaction has already been committed.");
	} else {
		throw new IllegalStateException();
	}

}
 
Example #15
Source File: TransactionImpl.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void commit() throws RollbackException,
                            HeuristicMixedException,
                            HeuristicRollbackException,
                            SecurityException,
                            IllegalStateException,
                            SystemException
{
   if (status == Status.STATUS_UNKNOWN)
      throw new IllegalStateException("Status unknown");

   if (status == Status.STATUS_MARKED_ROLLBACK)
      throw new IllegalStateException("Status marked rollback");

   finish(true);
}
 
Example #16
Source File: TransactionalTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Transactional(value = REQUIRED, dontRollbackOn = AnotherException.class)
public void anotherException(final AtomicInteger status) {
    try {
        OpenEJB.getTransactionManager().getTransaction().registerSynchronization(new Synchronization() {
            @Override
            public void beforeCompletion() {
                // no-op
            }

            @Override
            public void afterCompletion(final int state) {
                status.set(state);
            }
        });
    } catch (final RollbackException | SystemException e) {
        fail();
    }
    throw new AnotherException();
}
 
Example #17
Source File: TransactionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void commit() throws RollbackException,
                            HeuristicMixedException,
                            HeuristicRollbackException,
                            SecurityException,
                            IllegalStateException,
                            SystemException
{
   if (status == Status.STATUS_UNKNOWN)
      throw new IllegalStateException("Status unknown");

   if (status == Status.STATUS_MARKED_ROLLBACK)
      throw new IllegalStateException("Status marked rollback");

   finish(true);
}
 
Example #18
Source File: TxConnectionManagerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * RethrowAsSystemException.
 * @param context context
 * @param tx transaction
 * @param t throwable
 * @throws SystemException system exception
 */
public static void rethrowAsSystemException(String context, Transaction tx, Throwable t)
   throws SystemException
{
   if (t instanceof SystemException)
      throw (SystemException) t;

   if (t instanceof RuntimeException)
      throw (RuntimeException) t;

   if (t instanceof Error)
      throw (Error) t;

   if (t instanceof RollbackException)
      throw new IllegalStateException(context + " tx=" + tx + " marked for rollback.");

   throw new RuntimeException(context + " tx=" + tx + " got unexpected error ", t);
}
 
Example #19
Source File: UserTransactionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void commit() throws RollbackException,
                            HeuristicMixedException,
                            HeuristicRollbackException,
                            SecurityException,
                            IllegalStateException,
                            SystemException
{
   Transaction tx = registry.getTransaction();

   if (tx == null)
      throw new SystemException();

   if (tx.getStatus() == Status.STATUS_ROLLING_BACK ||
       tx.getStatus() == Status.STATUS_ROLLEDBACK ||
       tx.getStatus() == Status.STATUS_MARKED_ROLLBACK)
      throw new RollbackException();

   registry.commitTransaction();
}
 
Example #20
Source File: TransactionManagerDelegator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void commit() throws RollbackException, HeuristicMixedException,
                            HeuristicRollbackException, SecurityException, IllegalStateException,
                            SystemException
{
   tm.commit();
}
 
Example #21
Source File: TransactionManagerDelegator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public long getTimeLeftBeforeTransactionTimeout(boolean errorRollback) throws RollbackException
{
   if (tm instanceof org.jboss.tm.TransactionTimeoutConfiguration)
      return ((org.jboss.tm.TransactionTimeoutConfiguration)tm).getTimeLeftBeforeTransactionTimeout(errorRollback);

   return 0;
}
 
Example #22
Source File: XAStore.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
private XATransactionContext<K, V> getCurrentContext() {
  try {
    final Transaction transaction = transactionManagerWrapper.getTransactionManager().getTransaction();
    if (transaction == null) {
      throw new XACacheException("Cannot access XA cache outside of XA transaction scope");
    }
    EhcacheXAResource<K, V> xaResource = xaResources.get(transaction);
    if (xaResource == null) {
      xaResource = new EhcacheXAResource<>(underlyingStore, journal, transactionContextFactory);
      transactionManagerWrapper.registerXAResource(uniqueXAResourceId, xaResource);
      transactionManagerWrapper.getTransactionManager().getTransaction().enlistResource(xaResource);
      xaResources.put(transaction, xaResource);
      final EhcacheXAResource<K, V> finalXaResource = xaResource;
      transaction.registerSynchronization(new Synchronization() {
        @Override
        public void beforeCompletion() {
        }

        @Override
        public void afterCompletion(int status) {
          transactionManagerWrapper.unregisterXAResource(uniqueXAResourceId, finalXaResource);
          xaResources.remove(transaction);
        }
      });
    }
    XATransactionContext<K, V> currentContext = xaResource.getCurrentContext();
    if (currentContext.hasTimedOut()) {
      throw new XACacheException("Current XA transaction has timed out");
    }
    return currentContext;
  } catch (SystemException se) {
    throw new XACacheException("Cannot get current XA transaction", se);
  } catch (RollbackException re) {
    throw new XACacheException("XA Transaction has been marked for rollback only", re);
  }
}
 
Example #23
Source File: OutgoingAsyncTopicTest.java    From reladomo with Apache License 2.0 5 votes vote down vote up
@Test
public void testCloneSendPreservesNullProperties() throws NamingException, JMSException, RollbackException, RestartTopicException, XAException
{
    mithraTransaction = topicResourcesWithTransactionXid.startTransaction();

    InMemoryBytesMessage messageToSend = new InMemoryBytesMessage();
    messageToSend.writeBytes("msg1".getBytes());

    Future<Void> voidFuture = outTopic.sendSyncMessageClones(FastList.<Message>newListWith(messageToSend));
    topicResourcesWithTransactionXid.commit(mithraTransaction, FastList.<Future>newListWith(voidFuture), FastList.<JmsTopic>newList());

    Message messageRecvd = incomingTopic.receive(100);
    assertNull(messageRecvd.getStringProperty("Hello"));
}
 
Example #24
Source File: JtaTransactionManager.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Register a JTA synchronization on the JTA TransactionManager, for calling
 * {@code afterCompletion} on the given Spring TransactionSynchronizations.
 * <p>The default implementation registers the synchronizations on the
 * JTA 1.1 TransactionSynchronizationRegistry, if available, or on the
 * JTA TransactionManager's current Transaction - again, if available.
 * If none of the two is available, a warning will be logged.
 * <p>Can be overridden in subclasses, for specific JTA implementations.
 * @param txObject the current transaction object
 * @param synchronizations a List of TransactionSynchronization objects
 * @throws RollbackException if thrown by JTA methods
 * @throws SystemException if thrown by JTA methods
 * @see #getTransactionManager()
 * @see javax.transaction.Transaction#registerSynchronization
 * @see javax.transaction.TransactionSynchronizationRegistry#registerInterposedSynchronization
 */
protected void doRegisterAfterCompletionWithJtaTransaction(
		JtaTransactionObject txObject, List<TransactionSynchronization> synchronizations)
		throws RollbackException, SystemException {

	int jtaStatus = txObject.getUserTransaction().getStatus();
	if (jtaStatus == Status.STATUS_NO_TRANSACTION) {
		throw new RollbackException("JTA transaction already completed - probably rolled back");
	}
	if (jtaStatus == Status.STATUS_ROLLEDBACK) {
		throw new RollbackException("JTA transaction already rolled back (probably due to a timeout)");
	}

	if (this.transactionSynchronizationRegistry != null) {
		// JTA 1.1 TransactionSynchronizationRegistry available - use it.
		this.transactionSynchronizationRegistry.registerInterposedSynchronization(
				new JtaAfterCompletionSynchronization(synchronizations));
	}

	else if (getTransactionManager() != null) {
		// At least the JTA TransactionManager available - use that one.
		Transaction transaction = getTransactionManager().getTransaction();
		if (transaction == null) {
			throw new IllegalStateException("No JTA Transaction available");
		}
		transaction.registerSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
	}

	else {
		// No JTA TransactionManager available - log a warning.
		logger.warn("Participating in existing JTA transaction, but no JTA TransactionManager available: " +
				"cannot register Spring after-completion callbacks with outer JTA transaction - " +
				"processing Spring after-completion callbacks with outcome status 'unknown'");
		invokeAfterCompletion(synchronizations, TransactionSynchronization.STATUS_UNKNOWN);
	}
}
 
Example #25
Source File: OutgoingAsyncTopicTest.java    From reladomo with Apache License 2.0 5 votes vote down vote up
@Test
public void testCloneSendPreservesNonNullProperty() throws NamingException, JMSException, RollbackException, RestartTopicException, XAException
{
    mithraTransaction = topicResourcesWithTransactionXid.startTransaction();

    InMemoryBytesMessage messageToSend = new InMemoryBytesMessage();
    messageToSend.writeBytes("msg1".getBytes());
    messageToSend.setStringProperty("Hello", "World");

    Future<Void> voidFuture = outTopic.sendSyncMessageClones(FastList.<Message>newListWith(messageToSend));
    topicResourcesWithTransactionXid.commit(mithraTransaction, FastList.<Future>newListWith(voidFuture), FastList.<JmsTopic>newList());

    Message messageRecvd = incomingTopic.receive(100);
    assertEquals("World", messageRecvd.getStringProperty("Hello"));
}
 
Example #26
Source File: InterceptorBase.java    From tomee with Apache License 2.0 5 votes vote down vote up
private Exception unwrap(Exception e) {
    Exception error = e;
    while (error != null &&
            (ApplicationException.class.isInstance(error) || SystemException.class.isInstance(error) || TransactionRolledbackException.class.isInstance(error))) {
        final Throwable cause = error.getCause();
        if (cause == error) {
            break;
        }
        error = Exception.class.isInstance(cause) ? Exception.class.cast(cause) : null;
    }
    if (RollbackException.class.isInstance(error) && Exception.class.isInstance(error.getCause())) {
        error = Exception.class.cast(error.getCause());
    }
    return error;
}
 
Example #27
Source File: TransactionImpl.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void registerSynchronization(Synchronization sync) throws RollbackException,
                                                                 IllegalStateException,
                                                                 SystemException
{
   if (status == Status.STATUS_UNKNOWN)
      throw new IllegalStateException("Status unknown");

   syncs.add(sync);
}
 
Example #28
Source File: TransactionImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void checkForTransactionExtraIfNecessary() throws RollbackException, HeuristicMixedException,
		HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, SystemException {

	if (this.transactionalExtra != null) /* for ByteTCC */ {
		if (this.participantList.isEmpty() == false && this.participant == null) /* see initGetTransactionStrategy */ {
			this.participantRollback();
			throw new HeuristicRollbackException();
		} else if (this.participantList.size() > 1) {
			this.participantRollback();
			throw new HeuristicRollbackException();
		}
	} // end-if (this.transactionalExtra != null)

}
 
Example #29
Source File: CompensableTransactionImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
public synchronized void participantCommit(boolean opc) throws RollbackException, HeuristicMixedException,
		HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, SystemException {

	// Recover if transaction is recovered from tx-log.
	this.recoverIfNecessary();

	if (this.transactionStatus != Status.STATUS_COMMITTED) {
		this.fireCommit(); // TODO
	}

}
 
Example #30
Source File: InterceptorBase.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
private Exception unwrap(final Exception e) {
    Exception error = e;
    while (error != null && (SystemException.class.isInstance(error) || TransactionRolledbackException.class.isInstance(error))) {
        final Throwable cause = error.getCause();
        if (cause == error) {
            break;
        }
        error = Exception.class.isInstance(cause) ? Exception.class.cast(cause) : null;
    }
    if (RollbackException.class.isInstance(error) && Exception.class.isInstance(error.getCause())) {
        error = Exception.class.cast(error.getCause());
    }
    return error;
}