List of usage examples for org.springframework.transaction TransactionSystemException TransactionSystemException
public TransactionSystemException(String msg)
From source file:gov.nasa.jpl.docweb.spring.SesameTransactionObject.java
void setConnection(RepositoryConnection connection) throws RepositoryException { Validate.notNull(connection);/*w ww. ja va 2 s.c o m*/ if (this.connection != null && this.connection != connection) throw new TransactionSystemException("Change of connection detected in @Transactional managed code"); if (this.connection == null) connection.setAutoCommit(false); this.connection = connection; }
From source file:org.grails.datastore.mapping.redis.RedisTransaction.java
public void commit() { if (rollbackCalled) { throw new IllegalTransactionStateException( "Cannot call commit after rollback. Start another transaction first!"); }// ww w . j a v a2 s. c o m try { /*final Object[] objects =*/ redisTemplate.exec(); commitCalled = true; } catch (Exception e) { throw new TransactionSystemException( "Exception occurred committing back Redis transaction: " + e.getMessage()); } }
From source file:org.grails.datastore.mapping.redis.RedisTransaction.java
public void rollback() { if (rollbackCalled) { throw new UnexpectedRollbackException( "Cannot rollback Redis transaction. Transaction already rolled back!"); }//from w ww . java2 s . c om try { redisTemplate.discard(); rollbackCalled = true; } catch (Exception e) { throw new TransactionSystemException( "Exception occurred rolling back Redis transaction: " + e.getMessage()); } }
From source file:org.grails.datastore.mapping.cassandra.CassandraSession.java
@Override protected Transaction beginTransactionInternal() { throw new TransactionSystemException("Transactions are not supported by Cassandra"); }
From source file:org.develspot.data.orientdb.transaction.OrientDBTransactionManager.java
@Override protected void doCommit(DefaultTransactionStatus status) throws TransactionException { OrientDBTransactionObject txObject = (OrientDBTransactionObject) status.getTransaction(); OGraphDatabase connection = txObject.getConnectionHolder().getConnection(); if (status.isDebug()) { logger.debug("Commiting orientdb transaction on connection [" + connection + "]"); }//from w ww.j a v a 2 s . co m try { connection.commit(); } catch (Exception e) { throw new TransactionSystemException("Could not commit orientdb transaction:" + e.getMessage()); } }
From source file:org.develspot.data.orientdb.transaction.OrientDBTransactionManager.java
@Override protected void doRollback(DefaultTransactionStatus status) throws TransactionException { OrientDBTransactionObject txObject = (OrientDBTransactionObject) status.getTransaction(); OGraphDatabase connection = txObject.getConnectionHolder().getConnection(); if (status.isDebug()) { logger.debug("Rolling back transaction on connection [" + connection + "]"); }//from ww w. jav a2 s .c o m try { connection.rollback(); } catch (Exception e) { throw new TransactionSystemException("Could not rollback orientdb transaction: " + e.getMessage()); } }
From source file:org.fcrepo.camel.FcrepoTransactionManager.java
@Override protected void doCommit(final DefaultTransactionStatus status) { final FcrepoTransactionObject tx = (FcrepoTransactionObject) status.getTransaction(); final InputStream is = null; final String contentType = null; try {// ww w . j a v a2 s. c om getClient().post(URI.create(baseUrl + "/" + tx.getSessionId() + COMMIT)).body(is, contentType) .perform(); } catch (final FcrepoOperationFailedException ex) { LOGGER.debug("Transaction commit failed: ", ex); throw new TransactionSystemException("Could not commit fcrepo transaction"); } finally { tx.setSessionId(null); } }
From source file:org.fcrepo.camel.FcrepoTransactionManager.java
@Override protected void doRollback(final DefaultTransactionStatus status) { final FcrepoTransactionObject tx = (FcrepoTransactionObject) status.getTransaction(); try {/* w w w . ja v a2 s. c o m*/ getClient().post(URI.create(baseUrl + "/" + tx.getSessionId() + ROLLBACK)).perform(); } catch (final FcrepoOperationFailedException ex) { LOGGER.debug("Transaction rollback failed: ", ex); throw new TransactionSystemException("Could not rollback fcrepo transaction"); } finally { tx.setSessionId(null); } }
From source file:com.mothsoft.alexis.engine.textual.ParseResponseMessageListener.java
private Term findOrCreateTerm(final String value, final PartOfSpeech partOfSpeech) { final int maxTries = 20; int retryCount = maxTries; Term term = null;/*from w w w. ja v a 2 s . co m*/ while (term == null && retryCount > 0) { retryCount--; try { term = this.transactionTemplate.execute(new TransactionCallback<Term>() { public Term doInTransaction(TransactionStatus status) { try { Term term = ParseResponseMessageListener.this.termDao.find(value, partOfSpeech); if (term == null) { term = new Term(value, partOfSpeech); ParseResponseMessageListener.this.termDao.add(term); } return term; } catch (JpaSystemException e) { throw new TransactionSystemException(e.getLocalizedMessage()); } } }); } catch (TransactionException e) { if (retryCount == 0) { logger.error("Retried transaction " + maxTries + " times; failed every time!" + e, e); throw e; } else { logger.warn("Experienced transaction failure: " + e.getLocalizedMessage() + "; will retry!"); continue; } } } return term; }
From source file:com.newmainsoftech.spray.slingong.datastore.Slim3PlatformTransactionManager.java
@Override protected void doCommit(DefaultTransactionStatus defaultTransactionStatus) throws TransactionException { GlobalTransaction gtx = (GlobalTransaction) defaultTransactionStatus.getTransaction(); Set<GlobalTransactionState> gtxStateSet = getGlobalTransactionStates(gtx); // Sanity check on precondition ----------------------------------------------------------- /*/*from ww w .ja v a2 s .com*/ * This will be called at outermost transaction boundary (defaultTransactionStatus.isNewTransaction() * will return true). * When defaultTransactionStatus has been set for roll back, roll back doesn't need to be handled * within doCommit method. * When either defaultTransactionStatus's isGlobalRollbackOnly and shouldCommitOnGlobalRollbackOnly * returns true or its isLocalRollbackOnly returns true, then logic flow won't reach here and * roll back should have been performed by doRollback. */ if (defaultTransactionStatus.isRollbackOnly()) { throw new TransactionSystemException(String.format( "Unexpected system state: the transaction for the GlobalTransaction " + "instance (ID:%1$s) has been marked as roll-back only " + "(LocalRollbackOnly:%2$b, GlobalRollbackOnly:%3$b).", (gtxStateSet.contains(GlobalTransactionState.GlobalTransactionInstance) ? gtx.getId() : "null"), defaultTransactionStatus.isLocalRollbackOnly(), defaultTransactionStatus.isGlobalRollbackOnly())); } if (!defaultTransactionStatus.isNewTransaction()) { throw new TransactionSystemException(String.format( "Unexpected system state: attempted to commit from participation of an existing " + "transaction (of which GlobalTransacion Id is %1$s).", (gtxStateSet.contains(GlobalTransactionState.GlobalTransactionInstance) ? gtx.getId() : "null"))); } // ---------------------------------------------------------------------------------------- // Sanity check on gtx GlobalTransaction instance ----------------------------------------- if (!gtxStateSet.contains(GlobalTransactionState.ActiveGlobalTransaction)) { String message; if (!gtxStateSet.contains(GlobalTransactionState.GlobalTransactionInstance)) { message = "Unexpected system state: The GlobalTransaction object passed as the transaction " + "Object argument is null."; } else { message = String .format("Unexpected system state: The GlobalTransaction instance (ID:%1$s) passed as the " + "transaction Object argument is inactive.", gtx.getId()); } throw new IllegalTransactionStateException(message); } if (!gtxStateSet.contains(GlobalTransactionState.CurrentGlobalTransaction)) { /* The one possible case of the control flow reaching here is that GlobalTransaction object * is manually instantiated at the outside of Spring transaction framework, and it is left active. * * In nesting global transaction, easy to yield ConcurrentModificationException without care. * Nesting global transaction should be less necessary, since Slim3 isolate between (Global) * transactions and cannot change that isolation setting, and this uses Slim3 GlobalTransaction, * as GAE/J datastore API is not provide suspend feature as well. */ GlobalTransaction currentGtx = Datastore.getCurrentGlobalTransaction(); if (logger.isWarnEnabled()) { logger.warn(String.format( "Though active GlobalTransaction instance (ID:%1$s) is passed as transaction " + "Object argument, it's not current GlobalTransaction instance (ID:%2$s).", gtx.getId(), ((currentGtx instanceof GlobalTransaction) ? currentGtx.getId() : "null"))); } } // ---------------------------------------------------------------------------------------- boolean exceptionUp = false; try { gtx.commit(); slim3GtxObjMapThreadLocal.get().remove(gtx.getId()); if (logger.isInfoEnabled()) { logger.info(String.format("Slim3 GlobalTransaction (ID:%1$s) committed.", gtx.getId())); } } catch (Throwable throwable) { /* Set rollback only flag so calling processRollback method to roll back will occur at * commit method by AnnotationTransactionAspect, even for other exceptions than ones specified * for rollbackFor or rollbackForClassname attributes of @Transactional annotation. */ defaultTransactionStatus.setRollbackOnly(); exceptionUp = true; String message = String.format("Slim3 GlobalTransaction (ID:%1$s) failed on commit.", gtx.getId()); if ((throwable instanceof ConcurrentModificationException) || (throwable instanceof DeadlineExceededException)) { /* Slim3 should have already rolled back automatically on either * ConcurrentModificationException or DeadlineExceededException. * * About DeadlineExceededException case: It seems like no harm * will be made even active global transaction at * DeadlineExceededException case left behind. As looking * briefly through the Slim3 source codes, the locks by that * global transaction seems to be released while it rolls back * by DatastoreFilter, and itself seem to be removed from * TheadLocal stack of the global transactions. So, it won't be * returned by such Datastore.getCurrentGlobalTransaction() * method. See at * http://groups.google.com/group/slim3-user/browse_frm * /thread/e3d47d8f28c8e8d3 * /9e43553f3b56d1f2?tvc=1#9e43553f3b56d1f2 If it turns out * opposite, then that active global transaction can be cleared * some how at here for DeadlineExceededException case. */ message = String.format("Slim3 GlobalTransaction (ID:%1$s) failed on commit. %n" + "Slim3 must have already rolled back automatically behind " + "Spring transaction framework.", gtx.getId()); } throw new TransactionSystemException(message, throwable); } finally { if (gtx.isActive()) { if (exceptionUp) { if (logger.isInfoEnabled()) { logger.info(String.format( "GlobalTransaction instance (ID:%1$s) remains active after exception " + "durring commit attempt. That GlobalTransaction instance has not " + "been removed yet from slim3GtxObjMapThreadLocal member field.", gtx.getId(), this.getClass().getName())); } } else { if (logger.isWarnEnabled()) { logger.warn(String.format( "Unexpected system state: GlobalTransaction instance (ID:%1$s) " + "remains active even after commit attempt. That GlobalTransaction " + "instance was removed from slim3GtxObjMapThreadLocal member field.", gtx.getId(), this.getClass().getName())); } } } } }