Example usage for javax.transaction.xa XAException XAER_RMERR

List of usage examples for javax.transaction.xa XAException XAER_RMERR

Introduction

In this page you can find the example usage for javax.transaction.xa XAException XAER_RMERR.

Prototype

int XAER_RMERR

To view the source code for javax.transaction.xa XAException XAER_RMERR.

Click Source Link

Document

A resource manager error has occurred in the transaction branch.

Usage

From source file:org.nuxeo.ecm.core.storage.sql.jdbc.JDBCMapper.java

@Override
public void end(Xid xid, int flags) throws XAException {
    try {//  ww  w.ja v a2s. c om
        xaresource.end(xid, flags);
        if (logger.isLogEnabled()) {
            logger.log("XA end on " + systemToString(xid));
        }
    } catch (NullPointerException e) {
        // H2 when no active transaction
        logger.error("XA end error on " + systemToString(xid), e);
        throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
    } catch (XAException e) {
        if (flags != XAResource.TMFAIL) {
            logger.error("XA end error on " + systemToString(xid), e);
        }
        throw e;
    }
}

From source file:org.nuxeo.ecm.core.storage.sql.SessionImpl.java

@Override
public void end(Xid xid, int flags) throws XAException {
    boolean failed = true;
    try {//www.  j a va2s.c om
        if (flags != TMFAIL) {
            try {
                flush();
            } catch (Exception e) {
                String msg = "Exception during transaction commit";
                if (e instanceof ConcurrentUpdateStorageException) {
                    TransactionHelper.noteSuppressedException(e);
                    log.debug(msg, e);
                    // set rollback only manually instead of throwing,
                    // this avoids a spurious log in Geronimo
                    // TransactionImpl
                    // and has the same effect
                    TransactionHelper.setTransactionRollbackOnly();
                    return;
                } else {
                    log.error(msg, e);
                    throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
                }
            }
        }
        failed = false;
        mapper.end(xid, flags);
    } finally {
        if (failed) {
            mapper.end(xid, TMFAIL);
            // rollback done by tx manager
        }
    }
}

From source file:org.nuxeo.ecm.core.storage.sql.SessionImpl.java

protected void commitDone() throws XAException {
    inTransaction = false;/*from  w w  w . j a  va  2 s  .c  o m*/
    try {
        try {
            sendInvalidationsToOthers();
        } finally {
            checkThreadEnd();
        }
    } catch (Exception e) {
        log.error("Could not send invalidations", e);
        throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
    }
}

From source file:org.nuxeo.ecm.core.storage.sql.TransactionalSession.java

public void start(Xid xid, int flags) throws XAException {
    if (flags == TMNOFLAGS) {
        try {//  w  ww.  j  a va 2  s.  c  om
            session.processReceivedInvalidations();
        } catch (Exception e) {
            log.error("Could not start transaction", e);
            throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
        }
    }
    mapper.start(xid, flags);
    inTransaction = true;
    session.checkThreadStart();
}

From source file:org.nuxeo.ecm.core.storage.sql.TransactionalSession.java

public void end(Xid xid, int flags) throws XAException {
    boolean failed = true;
    try {//  ww w  .ja  v a 2 s . c om
        if (flags != TMFAIL) {
            try {
                session.flush();
            } catch (Exception e) {
                log.error("Could not end transaction", e);
                throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
            }
        }
        failed = false;
        mapper.end(xid, flags);
    } finally {
        if (failed) {
            try {
                mapper.end(xid, TMFAIL);
            } finally {
                rollback(xid);
            }
        }
    }
}

From source file:org.nuxeo.ecm.core.storage.sql.TransactionalSession.java

public void commit(Xid xid, boolean onePhase) throws XAException {
    try {/* ww  w  .  j ava 2 s . c om*/
        mapper.commit(xid, onePhase);
    } finally {
        inTransaction = false;
        try {
            try {
                session.sendInvalidationsToOthers();
            } finally {
                session.checkThreadEnd();
            }
        } catch (Exception e) {
            log.error("Could not commit transaction", e);
            throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
        }
    }
}

From source file:org.nuxeo.ecm.core.storage.sql.TransactionalSession.java

public void rollback(Xid xid) throws XAException {
    try {//from w ww  . j av a2  s  .  c om
        try {
            mapper.rollback(xid);
        } finally {
            session.rollback();
        }
    } finally {
        inTransaction = false;
        try {
            try {
                session.sendInvalidationsToOthers();
            } finally {
                session.checkThreadEnd();
            }
        } catch (Exception e) {
            log.error("Could not rollback transaction", e);
            throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
        }
    }
}