use of javax.transaction.SystemException in project geode by apache.
the class TransactionManagerImpl method getGlobalTransaction.
/**
* Get the Global Transaction associated with the calling thread
*/
GlobalTransaction getGlobalTransaction(Transaction txn) throws SystemException {
if (txn == null) {
String exception = LocalizedStrings.TransactionManagerImpl_TRANSACTIONMANAGERIMPL_GETGLOBALTRANSACTION_NO_TRANSACTION_EXISTS.toLocalizedString();
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (VERBOSE)
writer.fine(exception);
throw new SystemException(exception);
}
GlobalTransaction gtx = (GlobalTransaction) globalTransactionMap.get(txn);
return gtx;
}
use of javax.transaction.SystemException in project geode by apache.
the class TransactionManagerImpl method getTransaction.
/**
* Get the transaction associated with the calling thread
*
* @see javax.transaction.TransactionManager#getTransaction()
*/
public Transaction getTransaction() throws SystemException {
if (!isActive) {
throw new SystemException(LocalizedStrings.TransactionManagerImpl_TRANSACTIONMANAGER_INVALID.toLocalizedString());
}
Thread thread = Thread.currentThread();
Transaction txn = (Transaction) transactionMap.get(thread);
return txn;
}
use of javax.transaction.SystemException in project geode by apache.
the class ContextImpl method lookup.
/**
* Looks up object with binding name name in this context.
*
* @param name name to look up
* @return object reference bound to name name.
* @throws NoPermissionException if this context has been destroyed.
* @throws InvalidNameException if name is CompositeName that spans more than one naming system
* @throws NameNotFoundException if name can not be found.
* @throws NotContextException component of name is not bound to instance of ContextImpl, when
* name is not atomic name.
* @throws NamingException if any other naming error occurs
*
*/
public Object lookup(Name name) throws NamingException {
checkIsDestroyed();
try {
Name parsedName = getParsedName(name);
String nameComponent = parsedName.get(0);
Object res = ctxMaps.get(nameComponent);
if (res instanceof UserTransactionImpl) {
res = new UserTransactionImpl();
}
// if not found
if (!ctxMaps.containsKey(nameComponent)) {
throw new NameNotFoundException(LocalizedStrings.ContextImpl_NAME_0_NOT_FOUND.toLocalizedString(name));
} else // if this is a compound name
if (parsedName.size() > 1) {
if (res instanceof ContextImpl) {
res = ((ContextImpl) res).lookup(parsedName.getSuffix(1));
} else {
throw new NotContextException(LocalizedStrings.ContextImpl_EXPECTED_CONTEXTIMPL_BUT_FOUND_0.toLocalizedString(res));
}
}
return res;
} catch (NameNotFoundException e) {
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (writer.infoEnabled())
writer.info(LocalizedStrings.ContextImpl_CONTEXTIMPL_LOOKUP_ERROR_WHILE_LOOKING_UP_0, name, e);
throw new NameNotFoundException(LocalizedStrings.ContextImpl_NAME_0_NOT_FOUND.toLocalizedString(new Object[] { name }));
} catch (SystemException se) {
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (writer.severeEnabled())
writer.info(LocalizedStrings.ContextImpl_CONTEXTIMPL_LOOKUP_ERROR_WHILE_CREATING_USERTRANSACTION_OBJECT, se);
throw new NameNotFoundException(LocalizedStrings.ContextImpl_CONTEXTIMPL_LOOKUP_ERROR_WHILE_CREATING_USERTRANSACTION_OBJECT.toLocalizedString());
}
}
use of javax.transaction.SystemException in project ignite by apache.
the class CacheJtaManager method checkJta.
/** {@inheritDoc} */
@Override
public void checkJta() throws IgniteCheckedException {
if (jtaTm == null) {
try {
CacheTmLookup tmLookup = tmLookupRef.get();
if (tmLookup == null)
return;
jtaTm = tmLookup.getTm();
} catch (Exception e) {
throw new IgniteCheckedException("Failed to get transaction manager: " + e, e);
}
}
if (jtaTm != null) {
CacheJtaResource rsrc = this.rsrc.get();
if (rsrc == null || rsrc.isFinished()) {
try {
Transaction jtaTx = jtaTm.getTransaction();
if (jtaTx != null) {
GridNearTxLocal tx = cctx.tm().userTx();
if (tx == null) {
TransactionConfiguration tCfg = cctx.kernalContext().config().getTransactionConfiguration();
tx = cctx.tm().newTx(/*implicit*/
false, /*implicit single*/
false, null, tCfg.getDefaultTxConcurrency(), tCfg.getDefaultTxIsolation(), tCfg.getDefaultTxTimeout(), /*store enabled*/
true, /*tx size*/
0);
}
rsrc = new CacheJtaResource(tx, cctx.kernalContext());
if (useJtaSync)
jtaTx.registerSynchronization(rsrc);
else if (!jtaTx.enlistResource(rsrc))
throw new IgniteCheckedException("Failed to enlist XA resource to JTA user transaction.");
this.rsrc.set(rsrc);
}
} catch (SystemException e) {
throw new IgniteCheckedException("Failed to obtain JTA transaction.", e);
} catch (RollbackException e) {
throw new IgniteCheckedException("Failed to enlist XAResource to JTA transaction.", e);
}
}
}
}
use of javax.transaction.SystemException in project jackrabbit by apache.
the class UserTransactionImpl method begin.
/**
* @see javax.transaction.UserTransaction#begin
*/
public void begin() throws NotSupportedException, SystemException {
if (status != Status.STATUS_NO_TRANSACTION) {
throw new IllegalStateException("Transaction already active");
}
try {
for (Iterator it = xaResources.keySet().iterator(); it.hasNext(); ) {
XAResource resource = (XAResource) it.next();
XidImpl xid = (XidImpl) xaResources.get(resource);
resource.start(xid, XAResource.TMNOFLAGS);
}
status = Status.STATUS_ACTIVE;
} catch (XAException e) {
throw new SystemException("Unable to begin transaction: " + "XA_ERR=" + e.errorCode);
}
}
Aggregations