Package javax.transaction

Examples of javax.transaction.RollbackException


         throw new IllegalStateException("thread not associated with transaction");
      status = tx.getStatus();
      if (status == Status.STATUS_MARKED_ROLLBACK) {
         tx.setStatus(Status.STATUS_ROLLEDBACK);
         rollback();
         throw new RollbackException("Transaction status is Status.STATUS_MARKED_ROLLBACK");
      } else {
         tx.commit();
      }

      // Disassociate tx from thread.
View Full Code Here


            status = Status.STATUS_ROLLING_BACK;
            doCommit = false;
         }
         notifyAfterCompletion(doCommit ? Status.STATUS_COMMITTED : Status.STATUS_MARKED_ROLLBACK);
         status = doCommit ? Status.STATUS_COMMITTED : Status.STATUS_MARKED_ROLLBACK;
         if (!doCommit) throw new RollbackException("outcome is " + outcome + " status: " + status);
      }
      finally {
         // Disassociate tx from thread.
         tm_.setTransaction(null);
      }
View Full Code Here

         case Status.STATUS_COMMITTING:
            throw new IllegalStateException("already started committing. " + this);
         case Status.STATUS_COMMITTED:
            throw new IllegalStateException("already committed. " + this);
         case Status.STATUS_MARKED_ROLLBACK:
            throw new RollbackException("already marked for rollback " + this);
         case Status.STATUS_ROLLING_BACK:
            throw new RollbackException("already started rolling back. " + this);
         case Status.STATUS_ROLLEDBACK:
            throw new RollbackException("already rolled back. " + this);
         case Status.STATUS_NO_TRANSACTION:
            throw new IllegalStateException("no transaction. " + this);
         case Status.STATUS_UNKNOWN:
            throw new IllegalStateException("unknown state " + this);
         default:
View Full Code Here

        return initCause(new NamingException(), cause);
    }


    public static RollbackException newRollbackException(String message, Throwable cause) {
        return initCause(new RollbackException(message), cause);
    }
View Full Code Here

    public static RollbackException newRollbackException(String message, Throwable cause) {
        return initCause(new RollbackException(message), cause);
    }

    public static RollbackException newRollbackException(Throwable cause) {
        return initCause(new RollbackException(), cause);
    }
View Full Code Here

      // validate the status
      if (_status != Status.STATUS_MARKED_ROLLBACK) {
      } else if (_rollbackException != null) {
        throw RollbackExceptionWrapper.create(_rollbackException);
      } else
        throw new RollbackException(
            L.l("Can't enlist resource {0} because the transaction is marked rollback-only.",
                resource));

      if (_status == Status.STATUS_NO_TRANSACTION)
        throw new IllegalStateException(L.l(
View Full Code Here

    if (log.isLoggable(Level.FINE))
      log.fine(this + " rollback-only");

    if (_rollbackException == null) {
      _rollbackException = new RollbackException(L.l("Transaction marked rollback-only"));
      _rollbackException.fillInStackTrace();
    }
  }
View Full Code Here

      } catch (Throwable e) {
        setRollbackOnly(e);

        rollbackInt();

        RollbackException newException = new RollbackException(e.toString());
        newException.initCause(e);

        throw newException;
      }

      if (_status == Status.STATUS_MARKED_ROLLBACK) {
        rollbackInt();

        if (_rollbackException != null)
          throw new RollbackExceptionWrapper(
              L.l("Transaction can't commit because it has been marked rolled back\n  {0}",
                  _rollbackException), _rollbackException);
        else
          throw new RollbackException(
              L.l("Transaction can't commit because it has been marked rolled back."));
      }

      if (_resourceCount > 0) {
        _status = Status.STATUS_PREPARING;
View Full Code Here

        try {
          sync.beforeCompletion();
        } catch (RuntimeException e) {
          setRollbackOnly(e);

          RollbackException newException = new RollbackException(e.toString());
          newException.initCause(e);

          throw newException;
        } catch (Throwable e) {
          log.log(Level.FINE, e.toString(), e);
        }
      }
    }

    // server/16h2
    if (_synchronizations != null) {
      // env/06a2
      for (int i = 0; i < _synchronizations.size(); i++) {
      //for (int i = _synchronizations.size() - 1; i >= 0; i--) {
        Synchronization sync = _synchronizations.get(i);

        if (log.isLoggable(Level.FINEST))
          log.finest(this + " beforeCompletion " + sync);

        try {
          sync.beforeCompletion();
        } catch (RuntimeException e) {
          setRollbackOnly(e);

          RollbackException newException = new RollbackException(e.toString());
          newException.initCause(e);

          throw newException;
        } catch (Throwable e) {
          log.log(Level.FINE, e.toString(), e);
        }
View Full Code Here

      String msg = L.l("{0}: timed out after {1} seconds.", this,
                       String.valueOf(getTransactionTimeout()));

      log.warning(msg);

      RollbackException exn = new RollbackException(msg);

      setRollbackOnly(exn);

      // should not close at this point because there could be following
      // statements that also need to be rolled back
View Full Code Here

TOP

Related Classes of javax.transaction.RollbackException

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.