String.format( "FacetsJCAConnectionManagerImpl:: An Exception was caught while allocating a connection due to %s", ex.getMessage()); throw new ResourceException(exception, ex); } catch (SystemException ex) {
throw new ResourceException( String.format("JCAConnectionManagerImpl:: allocateConnection : in transaction due to %s", ex.getMessage()), ex); } catch (SystemException ex) {
Assert.fail(e.getMessage());
private void throwRollbackExceptionIfAny(boolean forceRollback) throws RollbackException { if (firstRollbackException != null) { if (forceRollback && FORCE_ROLLBACK_MESSAGE.equals(firstRollbackException.getMessage())) { //force rollback set. don't throw it. return; } throw firstRollbackException; } }
try { entityManager.getTransaction().begin(); ... entityManager.getTransaction().commit(); } catch (RollbackException e1) { System.out.println(e1.getMessage()); System.out.println(e1.getCause()); throw ...; }
@Override public void putResource(Object key, Object value) { if (!(value instanceof XAResource)) { throw new IllegalArgumentException(L.l("{0} is not an XA resource.", value)); } TransactionImpl transaction = _transactionManager.getTransaction(); if (transaction != null) { try { transaction.putResource(key, (XAResource) value); } catch (RollbackException e) { log.log(Level.WARNING, L.l("Error adding resoure to transaction: {0}", e.getMessage()), e); } catch (SystemException e) { log.log(Level.WARNING, L.l("Error adding resoure to transaction: {0}", e.getMessage()), e); } } else { throw new IllegalStateException(L.l("No active transaction.")); } }
/** * */ public void test05_singleTransactionCommit(){ try{ Account expected = new Account("123-45-6789","Joe","Cool",40000); Account actual = new Account(); ejbObject.openAccount(expected, new Boolean(false)); actual = ejbObject.retreiveAccount( expected.getSsn() ); assertNotNull( "The transaction was not commited. The record is null", actual ); assertEquals( "The transaction was not commited cleanly.", expected, actual ); } catch (RollbackException re){ fail("Transaction was rolledback. Received Exception "+re.getClass()+ " : "+re.getMessage()); } catch (Exception e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } }
/** * */ public void test05_singleTransactionCommit(){ try{ final Account expected = new Account("123-45-6789","Joe","Cool",40000); Account actual = new Account(); ejbObject.openAccount(expected, new Boolean(false)); actual = ejbObject.retreiveAccount( expected.getSsn() ); assertNotNull( "The transaction was not commited. The record is null", actual ); assertEquals( "The transaction was not commited cleanly.", expected, actual ); } catch (final RollbackException re){ fail("Transaction was rolledback. Received Exception "+re.getClass()+ " : "+re.getMessage()); } catch (final Exception e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } }
/** * */ public void test05_singleTransactionCommit(){ try{ Account expected = new Account("123-45-6789","Joe","Cool",40000); Account actual = new Account(); ejbObject.openAccount(expected, new Boolean(false)); actual = ejbObject.retreiveAccount( expected.getSsn() ); assertNotNull( "The transaction was not commited. The record is null", actual ); assertEquals( "The transaction was not commited cleanly.", expected, actual ); } catch (RollbackException re){ fail("Transaction was rolledback. Received Exception "+re.getClass()+ " : "+re.getMessage()); } catch (Exception e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } }
/** * */ public void test05_singleTransactionCommit(){ try{ Account expected = new Account("123-45-6789","Joe","Cool",40000); Account actual = new Account(); ejbObject.openAccount(expected, new Boolean(false)); actual = ejbObject.retreiveAccount( expected.getSsn() ); assertNotNull( "The transaction was not commited. The record is null", actual ); assertEquals( "The transaction was not commited cleanly.", expected, actual ); } catch (RollbackException re){ fail("Transaction was rolledback. Received Exception "+re.getClass()+ " : "+re.getMessage()); } catch (Exception e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } }
/** * */ public void test05_singleTransactionCommit(){ try{ final Account expected = new Account("123-45-6789","Joe","Cool",40000); Account actual = new Account(); ejbObject.openAccount(expected, new Boolean(false)); actual = ejbObject.retreiveAccount( expected.getSsn() ); assertNotNull( "The transaction was not commited. The record is null", actual ); assertEquals( "The transaction was not commited cleanly.", expected, actual ); } catch (final RollbackException re){ fail("Transaction was rolledback. Received Exception "+re.getClass()+ " : "+re.getMessage()); } catch (final Exception e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } }
/** * */ public void test05_singleTransactionCommit(){ try{ final Account expected = new Account("123-45-6789","Joe","Cool",40000); Account actual = new Account(); ejbObject.openAccount(expected, new Boolean(false)); actual = ejbObject.retreiveAccount( expected.getSsn() ); assertNotNull( "The transaction was not commited. The record is null", actual ); assertEquals( "The transaction was not commited cleanly.", expected, actual ); } catch (final RollbackException re){ fail("Transaction was rolledback. Received Exception "+re.getClass()+ " : "+re.getMessage()); } catch (final Exception e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } }
public void put(Object key, Object value, Date expired) { Map<String, Object> map = new HashMap<String, Object>(3); map.put(RESOURCE, value); if (expired != null) { map.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, expired.getTime()); } cache.put(createFqn(key), map); Transaction transaction = cache.getInvocationContext().getTransaction(); try { // TODO: to review if ((transaction != null) && (transaction.getStatus() == Status.STATUS_ACTIVE)) { transaction.commit(); } } catch (SystemException e) { LOGGER.error(e.getMessage(), e); } catch (SecurityException e) { LOGGER.error(e.getMessage(), e); } catch (IllegalStateException e) { LOGGER.error(e.getMessage(), e); } catch (RollbackException e) { LOGGER.error(e.getMessage(), e); } catch (HeuristicMixedException e) { LOGGER.error(e.getMessage(), e); } catch (HeuristicRollbackException e) { LOGGER.error(e.getMessage(), e); } }
private Views getViews() { Transaction tx = txLocal.getTransaction(); GlobalTxSynchronization globalSync; try { globalSync = txLocal.getGlobalSynchronization(tx); } catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); } catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); } if(globalSync == null) throw new IllegalStateException("Global transaction synchronization is not available for transaction " + tx); Views views = (Views) globalSync.getTxLocal(viewsTxLocalKey); if(views == null) { views = new Views(tx); globalSync.putTxLocal(viewsTxLocalKey, views); globalSync.addSynchronization(new SchemaSynchronization(views)); } return views; }
public String updateKeyValueDatabase(String key, String value) { EntityManager entityManager = entityManagerFactory.createEntityManager(); try { userTransaction.begin(); entityManager.joinTransaction(); String result = updateKeyValueDatabase(entityManager, key, value); userTransaction.commit(); return result; } catch (RollbackException e) { Throwable t = e.getCause(); return t != null ? t.getMessage() : e.getMessage(); } catch (Exception e) { return e.getMessage(); } finally { try { if (userTransaction.getStatus() == Status.STATUS_ACTIVE) userTransaction.rollback(); } catch (Throwable e) { } entityManager.close(); } }
/** * Commits transaction. */ public void commit() { try { TransactionImpl xa = getTransaction(); if (xa != null && xa.isRollbackOnly()) _ut.rollback(); else _ut.commit(); } catch (RuntimeException e) { throw e; } catch (RollbackException e) { throw new TransactionRolledbackLocalException(e.getMessage(), e); } catch (HeuristicMixedException e) { throw new TransactionRolledbackLocalException(e.getMessage(), e); } catch (HeuristicRollbackException e) { throw new TransactionRolledbackLocalException(e.getMessage(), e); } catch (Exception e) { throw new EJBException(e); } }
public void testTimeout() throws Exception { btm.setTransactionTimeout(1); btm.begin(); CountingSynchronization sync = new CountingSynchronization(); btm.getTransaction().registerSynchronization(sync); Thread.sleep(2000); assertEquals(Status.STATUS_MARKED_ROLLBACK, btm.getTransaction().getStatus()); try { btm.commit(); fail("commit should have thrown an RollbackException"); } catch (RollbackException ex) { assertEquals("transaction timed out and has been rolled back", ex.getMessage()); } assertEquals(1, sync.beforeCount); assertEquals(1, sync.afterCount); }
public void testTimeout() throws Exception { btm.setTransactionTimeout(1); btm.begin(); CountingSynchronization sync = new CountingSynchronization(); btm.getTransaction().registerSynchronization(sync); Thread.sleep(2000); assertEquals(Status.STATUS_MARKED_ROLLBACK, btm.getTransaction().getStatus()); try { btm.commit(); fail("commit should have thrown an RollbackException"); } catch (RollbackException ex) { assertEquals("transaction timed out and has been rolled back", ex.getMessage()); } assertEquals(1, sync.beforeCount); assertEquals(1, sync.afterCount); }
public void testMarkedRollback() throws Exception { btm.begin(); CountingSynchronization sync = new CountingSynchronization(); btm.getTransaction().registerSynchronization(sync); btm.setRollbackOnly(); assertEquals(Status.STATUS_MARKED_ROLLBACK, btm.getTransaction().getStatus()); try { btm.commit(); fail("commit should have thrown an RollbackException"); } catch (RollbackException ex) { assertEquals("transaction was marked as rollback only and has been rolled back", ex.getMessage()); } assertEquals(1, sync.beforeCount); assertEquals(1, sync.afterCount); }
public void testMarkedRollback() throws Exception { btm.begin(); CountingSynchronization sync = new CountingSynchronization(); btm.getTransaction().registerSynchronization(sync); btm.setRollbackOnly(); assertEquals(Status.STATUS_MARKED_ROLLBACK, btm.getTransaction().getStatus()); try { btm.commit(); fail("commit should have thrown an RollbackException"); } catch (RollbackException ex) { assertEquals("transaction was marked as rollback only and has been rolled back", ex.getMessage()); } assertEquals(1, sync.beforeCount); assertEquals(1, sync.afterCount); }