Package org.springframework.transaction

Examples of org.springframework.transaction.UnexpectedRollbackException


    PlatformTransactionManager ptm = mock(PlatformTransactionManager.class);

    TransactionStatus status = mock(TransactionStatus.class);
    given(ptm.getTransaction(txatt)).willReturn(status);
    UnexpectedRollbackException ex = new UnexpectedRollbackException("foobar", null);
    willThrow(ex).given(ptm).commit(status);

    TestBean tb = new TestBean();
    ITestBean itb = (ITestBean) advised(tb, ptm, tas);
View Full Code Here


      }
      processRollback(defStatus);
      // Throw UnexpectedRollbackException only at outermost transaction boundary
      // or if explicitly asked to.
      if (status.isNewTransaction() || isFailEarlyOnGlobalRollbackOnly()) {
        throw new UnexpectedRollbackException(
            "Transaction rolled back because it has been marked as rollback-only");
      }
      return;
    }
View Full Code Here

          doCommit(status);
        }
        // Throw UnexpectedRollbackException if we have a global rollback-only
        // marker but still didn't get a corresponding exception from commit.
        if (globalRollbackOnly) {
          throw new UnexpectedRollbackException(
              "Transaction silently rolled back because it has been marked as rollback-only");
        }
      }
      catch (UnexpectedRollbackException ex) {
        // can only be caused by doCommit
View Full Code Here

      int jtaStatus = txObject.getUserTransaction().getStatus();
      if (jtaStatus == Status.STATUS_NO_TRANSACTION) {
        // Should never happen... would have thrown an exception before
        // and as a consequence led to a rollback, not to a commit call.
        // In any case, the transaction is already fully cleaned up.
        throw new UnexpectedRollbackException("JTA transaction already completed - probably rolled back");
      }
      if (jtaStatus == Status.STATUS_ROLLEDBACK) {
        // Only really happens on JBoss 4.2 in case of an early timeout...
        // Explicit rollback call necessary to clean up the transaction.
        // IllegalStateException expected on JBoss; call still necessary.
        try {
          txObject.getUserTransaction().rollback();
        }
        catch (IllegalStateException ex) {
          if (logger.isDebugEnabled()) {
            logger.debug("Rollback failure with transaction already marked as rolled back: " + ex);
          }
        }
        throw new UnexpectedRollbackException("JTA transaction already rolled back (probably due to a timeout)");
      }
      txObject.getUserTransaction().commit();
    }
    catch (RollbackException ex) {
      throw new UnexpectedRollbackException(
          "JTA transaction unexpectedly rolled back (maybe due to a timeout)", ex);
    }
    catch (HeuristicMixedException ex) {
      throw new HeuristicCompletionException(HeuristicCompletionException.STATE_MIXED, ex);
    }
View Full Code Here

        logger.debug("Committing JMS transaction on Session [" + session + "]");
      }
      session.commit();
    }
    catch (TransactionRolledBackException ex) {
      throw new UnexpectedRollbackException("JMS transaction rolled back", ex);
    }
    catch (JMSException ex) {
      throw new TransactionSystemException("Could not commit JMS transaction", ex);
    }
  }
View Full Code Here

      }
      processRollback(defStatus);
      // Throw UnexpectedRollbackException only at outermost transaction boundary
      // or if explicitly asked to.
      if (status.isNewTransaction() || isFailEarlyOnGlobalRollbackOnly()) {
        throw new UnexpectedRollbackException(
            "Transaction rolled back because it has been marked as rollback-only");
      }
      return;
    }
View Full Code Here

          doCommit(status);
        }
        // Throw UnexpectedRollbackException if we have a global rollback-only
        // marker but still didn't get a corresponding exception from commit.
        if (globalRollbackOnly) {
          throw new UnexpectedRollbackException(
              "Transaction silently rolled back because it has been marked as rollback-only");
        }
      }
      catch (UnexpectedRollbackException ex) {
        // can only be caused by doCommit
View Full Code Here

      int jtaStatus = txObject.getUserTransaction().getStatus();
      if (jtaStatus == Status.STATUS_NO_TRANSACTION) {
        // Should never happen... would have thrown an exception before
        // and as a consequence led to a rollback, not to a commit call.
        // In any case, the transaction is already fully cleaned up.
        throw new UnexpectedRollbackException("JTA transaction already completed - probably rolled back");
      }
      if (jtaStatus == Status.STATUS_ROLLEDBACK) {
        // Only really happens on JBoss 4.2 in case of an early timeout...
        // Explicit rollback call necessary to clean up the transaction.
        // IllegalStateException expected on JBoss; call still necessary.
        try {
          txObject.getUserTransaction().rollback();
        }
        catch (IllegalStateException ex) {
          if (logger.isDebugEnabled()) {
            logger.debug("Rollback failure with transaction already marked as rolled back: " + ex);
          }
        }
        throw new UnexpectedRollbackException("JTA transaction already rolled back (probably due to a timeout)");
      }
      txObject.getUserTransaction().commit();
    }
    catch (RollbackException ex) {
      throw new UnexpectedRollbackException(
          "JTA transaction unexpectedly rolled back (maybe due to a timeout)", ex);
    }
    catch (HeuristicMixedException ex) {
      throw new HeuristicCompletionException(HeuristicCompletionException.STATE_MIXED, ex);
    }
View Full Code Here

          return;
        }
        failed = true;
        status.setRollbackOnly();
        super.doRollback(status);
        throw new UnexpectedRollbackException("Planned");
      }
    };

    factory.setBeanName("stepName");
    factory.setTransactionManager(transactionManager);
View Full Code Here

    taskletStep.setTransactionManager(new ResourcelessTransactionManager() {
      @Override
      protected void doCommit(DefaultTransactionStatus status) throws TransactionException {
        super.doRollback(status);
        throw new UnexpectedRollbackException("bar");
      }
    });

    taskletStep.setTasklet(new Tasklet() {
View Full Code Here

TOP

Related Classes of org.springframework.transaction.UnexpectedRollbackException

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.