use of javax.resource.ResourceException in project geode by apache.
the class JCALocalTransaction method commit.
@Override
public void commit() throws ResourceException {
LogWriter logger = this.cache.getLogger();
if (logger.fineEnabled()) {
logger.fine("JCALocalTransaction:invoked commit");
}
TXStateProxy tsp = this.gfTxMgr.getTXState();
if (tsp != null && this.tid != tsp.getTransactionId()) {
throw new IllegalStateException("Local Transaction associated with Tid = " + this.tid + " attempting to commit a different transaction");
}
try {
this.gfTxMgr.commit();
this.tid = null;
} catch (Exception e) {
// TODO: consider wrapping the cause
throw new LocalTransactionException(e.toString());
}
}
use of javax.resource.ResourceException in project geode by apache.
the class JCALocalTransaction method rollback.
@Override
public void rollback() throws ResourceException {
TXStateProxy tsp = this.gfTxMgr.getTXState();
if (tsp != null && this.tid != tsp.getTransactionId()) {
throw new IllegalStateException("Local Transaction associated with Tid = " + this.tid + " attempting to commit a different transaction");
}
LogWriter logger = this.cache.getLogger();
if (logger.fineEnabled()) {
logger.fine("JCALocalTransaction:invoked rollback");
}
try {
this.gfTxMgr.rollback();
} catch (IllegalStateException ise) {
// It is possible that the GFE transaction has already been rolled back.
if (ise.getMessage().equals(LocalizedStrings.TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION.toLocalizedString())) {
// ignore
} else {
throw new ResourceException(ise);
}
} catch (RuntimeException e) {
throw new ResourceException(e);
} finally {
this.tid = null;
}
}
use of javax.resource.ResourceException in project geode by apache.
the class JCAConnectionManagerImpl method allocateConnection.
/*
* allocates a ManagedConnection from the ConnectionPool or creates a new
* ManagedConnection. @param javax.resource.spi.ManagedConnectionFactory
*
* @param javax.resource.spi.ConnectionRequestInfo
*
* @throws ResourceException
*/
public Object allocateConnection(ManagedConnectionFactory mcf, ConnectionRequestInfo reqInfo) throws ResourceException {
if (!isActive) {
throw new ResourceException(LocalizedStrings.JCAConnectionManagerImpl_JCACONNECTIONMANAGERIMPLALLOCATECONNECTIONNO_VALID_CONNECTION_AVAILABLE.toLocalizedString());
}
ManagedConnection conn = null;
try {
conn = (ManagedConnection) mannPoolCache.getPooledConnectionFromPool();
} catch (PoolException ex) {
// ex.printStackTrace();
throw new ResourceException(LocalizedStrings.JCAConnectionManagerImpl_JCACONNECTIONMANAGERIMPL_ALLOCATECONNECTION_IN_GETTING_CONNECTION_FROM_POOL_DUE_TO_0.toLocalizedString(ex.getMessage()), ex);
}
// Transaction Manager.
try {
synchronized (this) {
if (transManager == null) {
transManager = JNDIInvoker.getTransactionManager();
}
}
Transaction txn = transManager.getTransaction();
if (txn != null) {
// Check if Data Source provides XATransaction
// if(configs.getTransactionType = "XATransaction")
XAResource xar = conn.getXAResource();
txn.enlistResource(xar);
// Asif :Add in the Map after successful registration of XAResource
xaResourcesMap.put(conn, xar);
// else throw a resource exception
}
} catch (RollbackException ex) {
throw new ResourceException(LocalizedStrings.JCAConnectionManagerImpl_JCACONNECTIONMANAGERIMPL_ALLOCATECONNECTION_IN_TRANSACTION_DUE_TO_0.toLocalizedString(ex.getMessage()), ex);
} catch (SystemException ex) {
throw new ResourceException(LocalizedStrings.JCAConnectionManagerImpl_JCACONNECTIONMANAGERIMPL_ALLOCATECONNECTION_SYSTEM_EXCEPTION_DUE_TO_0.toLocalizedString(ex.getMessage()), ex);
}
return conn.getConnection(subject, reqInfo);
}
use of javax.resource.ResourceException in project geode by apache.
the class ManagedPoolCacheImpl method getNewPoolConnection.
/**
* Creates a new connection for the managed connection pool.
*
* @return the managed connection from the EIS as ManagedConnection object.
* @throws PoolException
*/
@Override
public Object getNewPoolConnection() throws PoolException {
ManagedConnection manConn = null;
try {
manConn = connFactory.createManagedConnection(sub, connReqInfo);
} catch (ResourceException rex) {
rex.printStackTrace();
throw new PoolException(LocalizedStrings.ManagedPoolCacheImpl_MANAGEDPOOLCACHEIMPLGETNEWCONNECTION_EXCEPTION_IN_CREATING_NEW_MANAGED_POOLEDCONNECTION.toLocalizedString(), rex);
}
manConn.addConnectionEventListener((javax.resource.spi.ConnectionEventListener) connEventListner);
return manConn;
}
use of javax.resource.ResourceException in project jackrabbit by apache.
the class JCAManagedConnection method openSession.
/**
* Create a new session.
*/
private Session openSession() throws ResourceException {
try {
Session session = mcf.getRepository().login(cri.getCredentials(), cri.getWorkspace());
log("Created session (" + session + ")");
return session;
} catch (RepositoryException e) {
log("Failed to create session", e);
ResourceException exception = new ResourceException("Failed to create session: " + e.getMessage());
exception.initCause(e);
throw exception;
}
}
Aggregations