use of org.apache.openejb.SystemException in project tomee by apache.
the class JtaTransactionPolicy method resumeTransaction.
protected void resumeTransaction(final Transaction tx) throws SystemException {
try {
if (tx == null) {
txLogger.debug("TX {0}: No transaction to resume", transactionType);
} else {
txLogger.debug("TX {0}: Resuming transaction {1}", transactionType, tx);
transactionManager.resume(tx);
}
} catch (final InvalidTransactionException ite) {
txLogger.error("Could not resume the client's transaction, the transaction is no longer valid: {0}", ite.getMessage());
throw new SystemException(ite);
} catch (final IllegalStateException e) {
txLogger.error("Could not resume the client's transaction: {0}", e.getMessage());
throw new SystemException(e);
} catch (final javax.transaction.SystemException e) {
txLogger.error("Could not resume the client's transaction: The transaction reported a system exception: {0}", e.getMessage());
throw new SystemException(e);
}
}
use of org.apache.openejb.SystemException in project tomee by apache.
the class EndpointHandler method deliverMessage.
public Object deliverMessage(final Method method, final Object[] args) throws Throwable {
boolean callBeforeAfter = false;
// verify current state
switch(state) {
case NONE:
try {
beforeDelivery(method);
} catch (final ApplicationServerInternalException e) {
throw (EJBException) new EJBException().initCause(e.getCause());
}
callBeforeAfter = true;
state = State.METHOD_CALLED;
break;
case BEFORE_CALLED:
state = State.METHOD_CALLED;
break;
case RELEASED:
throw new IllegalStateException("Message endpoint factory has been released");
case METHOD_CALLED:
case SYSTEM_EXCEPTION:
throw new IllegalStateException("The last message delivery must be completed with an afterDeliver before another message can be delivered");
}
Throwable throwable = null;
Object value = null;
try {
// deliver the message
value = container.invoke(instance, method, null, wrapMessageForAmq5(args));
} catch (final SystemException se) {
throwable = se.getRootCause() != null ? se.getRootCause() : se;
state = State.SYSTEM_EXCEPTION;
} catch (final ApplicationException ae) {
throwable = ae.getRootCause() != null ? ae.getRootCause() : ae;
} finally {
// if the adapter is not using before/after, we must call afterDelivery to clean up
if (callBeforeAfter) {
try {
afterDelivery();
} catch (final ApplicationServerInternalException e) {
throwable = throwable == null ? e.getCause() : throwable;
} catch (final UnavailableException e) {
throwable = throwable == null ? e : throwable;
}
}
}
if (throwable != null) {
throwable.printStackTrace();
if (isValidException(method, throwable)) {
throw throwable;
} else {
throw new EJBException().initCause(throwable);
}
}
return value;
}
Aggregations