private void registerSynchronization(Synchronization synchronization) { try { final Transaction tx = this.getTransaction(); // register for lifecycle events of transaction tx.registerSynchronization(synchronization); } catch (RollbackException e) { throw new EJBException(e); } catch (SystemException e) { throw new EJBException(e); } }
/** * {@inheritDoc} */ @Override public void cancel() throws IllegalStateException, EJBException { try { timerService.cancelTimer(this); } catch (InterruptedException e) { throw new EJBException(e); } }
public void handleException(IOException cause) { receiverInvocationContext.requestFailed(new EJBException(cause), getRetryExecutor()); }
public void handleClosed() { receiverInvocationContext.requestFailed(new EJBException(new ClosedChannelException()), getRetryExecutor()); }
protected Object invokeInNoTx(InterceptorContext invocation, final EJBComponent component) throws Exception { try { return invocation.proceed(); } catch (Error e) { throw EjbLogger.ROOT_LOGGER.unexpectedError(e); } catch (EJBException e) { throw e; } catch (RuntimeException e) { ApplicationExceptionDetails ae = component.getApplicationException(e.getClass(), invocation.getMethod()); throw ae != null ? e : new EJBException(e); } catch (Exception e) { throw e; } catch (Throwable t) { throw new EJBException(new UndeclaredThrowableException(t)); } }
private void safeResume(final Transaction tx) { try { ContextTransactionManager.getInstance().resume(tx); } catch (Exception e) { throw new EJBException(e); } }
private void safeSuspend() { try { ContextTransactionManager.getInstance().suspend(); } catch (SystemException e) { throw new EJBException(e); } }
@Override public final EJBException timerServiceWithIdNotRegistered(final String timedObjectId) { final EJBException result = new EJBException(String.format(getLoggingLocale(), timerServiceWithIdNotRegistered$str(), timedObjectId)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String timerHandleIsNotActive = "WFLYEJB0339: Timer for handle: %s is not active";
@Override public final EJBException acquireSemaphoreInterrupted() { final EJBException result = new EJBException(String.format(getLoggingLocale(), acquireSemaphoreInterrupted$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String isDeprecatedIllegalState = "WFLYEJB0380: %s is deprecated";
@Override public final EJBException cannotCallGetPKOnSessionBean() { final EJBException result = new EJBException(String.format(getLoggingLocale(), cannotCallGetPKOnSessionBean$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String ejb2xViewNotApplicableForSingletonBeans = "WFLYEJB0076: Singleton beans cannot have EJB 2.x views";
@Override public final EJBException cannotBeginUserTransaction() { final EJBException result = new EJBException(String.format(getLoggingLocale(), cannotBeginUserTransaction$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final EJBException operationInterrupted() { final EJBException result = new EJBException(String.format(getLoggingLocale(), operationInterrupted$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String cannotConvertToStateful = "EJBCLIENT000067: Cannot convert %s to stateful";
@Override public final EJBException ejbNotStateful(final String serverMessage) { final EJBException result = new EJBException(String.format(getLoggingLocale(), ejbNotStateful$str(), serverMessage)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String remoteMessageNoSuchEJB = "No such EJB: %s";
@Override public final EJBException failedToAcquirePermit(final long timeout, final TimeUnit timeUnit) { final EJBException result = new EJBException(String.format(getLoggingLocale(), failedToAcquirePermit$str(), timeout, timeUnit)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String acquireSemaphoreInterrupted = "WFLYEJB0379: Acquire semaphore was interrupted";
@Override public final EJBException invalidViewTypeForInvocation(final String serverMessage) { final EJBException result = new EJBException(String.format(getLoggingLocale(), invalidViewTypeForInvocation$str(), serverMessage)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String internalSystemErrorWithTx = "EJBCLIENT000507: Internal server error occurred while processing a transaction";
@Override public final EJBException txPresentForNeverTxAttribute() { final EJBException result = new EJBException(String.format(getLoggingLocale(), txPresentForNeverTxAttribute$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final EJBException failToCallBusinessOnNonePublicMethod(final Method method) { final EJBException result = new EJBException(String.format(getLoggingLocale(), failToCallBusinessOnNonePublicMethod$str(), method)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String componentInstanceNotAvailable = "WFLYEJB0225: Component instance isn't available for invocation: %s";
@Override public final EJBException transactionInUnexpectedState(final Transaction tx, final String txStatus) { final EJBException result = new EJBException(String.format(getLoggingLocale(), transactionInUnexpectedState$str(), tx, txStatus)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String timerServiceMethodNotAllowedForSFSB = "WFLYEJB0449: Timerservice API is not allowed on stateful session bean %s";
@Override public final EJBException unexpectedError(final Throwable cause) { final EJBException result = new EJBException(String.format(getLoggingLocale(), unexpectedError$str())); result.initCause(cause); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String transactionNotComplete1 = "WFLYEJB0443: EJB 3.1 FR 13.3.3: BMT bean %s should complete transaction before returning.";
private static void handleThrowable(Throwable t, StatefulSessionComponentInstance statefulSessionComponentInstance) { ROOT_LOGGER.discardingStatefulComponent(statefulSessionComponentInstance, t); try { // discard the SFSB instance statefulSessionComponentInstance.discard(); } finally { // release the lock associated with the SFSB instance releaseLock(statefulSessionComponentInstance); } // throw back an appropriate exception if (t instanceof RuntimeException) throw (RuntimeException) t; if (t instanceof Error) throw (Error) t; throw (EJBException) new EJBException().initCause(t); } }