use of javax.ejb.EJBException in project Payara by payara.
the class EJBTimerServiceWrapper method createTimerInternal.
private Timer createTimerInternal(Date initialExpiration, long intervalDuration, TimerConfig tc) throws IllegalArgumentException, IllegalStateException, EJBException {
checkIntervalDuration(intervalDuration);
TimerPrimaryKey timerId = null;
try {
timerId = timerService_.createTimer(ejbDescriptor_.getUniqueId(), ejbDescriptor_.getApplication().getUniqueId(), getTimedObjectPrimaryKey(), initialExpiration, intervalDuration, tc);
} catch (CreateException ce) {
EJBException ejbEx = new EJBException();
ejbEx.initCause(ce);
throw ejbEx;
}
return new TimerWrapper(timerId, timerService_);
}
use of javax.ejb.EJBException in project Payara by payara.
the class EJBTimerServiceWrapper method getTimers.
public Collection<Timer> getTimers() throws IllegalStateException, EJBException {
checkCallPermission();
Collection timerIds = new HashSet();
if (ejbContext_.isTimedObject()) {
try {
timerIds = timerService_.getTimerIds(ejbDescriptor_.getUniqueId(), getTimedObjectPrimaryKey());
} catch (Exception fe) {
EJBException ejbEx = new EJBException();
ejbEx.initCause(fe);
throw ejbEx;
}
}
Collection<Timer> timerWrappers = new HashSet();
for (Iterator iter = timerIds.iterator(); iter.hasNext(); ) {
TimerPrimaryKey next = (TimerPrimaryKey) iter.next();
timerWrappers.add(new TimerWrapper(next, timerService_));
}
return timerWrappers;
}
use of javax.ejb.EJBException in project Payara by payara.
the class EjbContainerServicesImpl method remove.
public void remove(Object ejbRef) {
EJBLocalObjectImpl localObjectImpl = getEJBLocalObject(ejbRef);
if (localObjectImpl == null) {
throw new UnsupportedOperationException("Invalid ejb ref");
}
Container container = localObjectImpl.getContainer();
EjbDescriptor ejbDesc = container.getEjbDescriptor();
boolean isStatefulBean = false;
if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
isStatefulBean = sessionDesc.isStateful();
}
if (!isStatefulBean) {
// stateless/singleton references via 299 could fail until bug is fixed.
return;
// TODO reenable this after bug is fixed
// throw new UnsupportedOperationException("ejbRef for ejb " +
// ejbDesc.getName() + " is not a stateful bean ");
}
try {
localObjectImpl.remove();
} catch (EJBException e) {
LogFacade.getLogger().log(Level.FINE, "EJBException during remove. ", e);
} catch (javax.ejb.RemoveException re) {
throw new NoSuchEJBException(re.getMessage(), re);
}
}
use of javax.ejb.EJBException in project Payara by payara.
the class InvocationHandlerUtil method throwLocalException.
public static void throwLocalException(Throwable t, Class[] declaredExceptions) throws Throwable {
Throwable toThrow;
if ((t instanceof java.lang.RuntimeException) || (isDeclaredException(t, declaredExceptions))) {
toThrow = t;
} else {
toThrow = new EJBException(t.getMessage());
toThrow.initCause(t);
}
throw toThrow;
}
use of javax.ejb.EJBException in project Payara by payara.
the class AsynchronousTask method releaseContext.
/**
* Called from preInvoke which is called from the EJBObject for local and
* remote invocations.
*/
public void releaseContext(EjbInvocation inv) {
SessionContextImpl sc = (SessionContextImpl) inv.context;
// any instance lock is released in the finally block.
try {
// check if the bean was destroyed
if (sc.getState() == BeanState.DESTROYED)
return;
// we're sure that no concurrent thread can be using this
// context, so no need to synchronize.
Transaction tx = sc.getTransaction();
// If this was an invocation of a remove-method
if (inv.invocationInfo.removalInfo != null) {
InvocationInfo invInfo = inv.invocationInfo;
EjbRemovalInfo removeInfo = invInfo.removalInfo;
if (retainAfterRemoveMethod(inv, removeInfo)) {
_logger.log(Level.FINE, "Skipping destruction of SFSB " + invInfo.ejbName + " after @Remove method " + invInfo.method + " due to (retainIfException" + " == true) and exception " + inv.exception);
} else {
try {
destroyBean(inv, sc);
} catch (Throwable t) {
_logger.log(Level.FINE, "@Remove.preDestroy exception", t);
}
// Explicitly null out transaction association in bean's context.
// Otherwise, forceDestroyBean() will mark that tx for rollback,
// which could incorrectly rollback a client-propagated transaction.
sc.setTransaction(null);
forceDestroyBean(sc);
// The bean has been detroyed so just skip any remaining processing.
return;
}
}
if (tx == null || tx.getStatus() == Status.STATUS_NO_TRANSACTION) {
// container.afterCompletion() was already called.
if (sc.getState() != BeanState.READY) {
if (sc.isAfterCompletionDelayed()) {
// been called concurrently with this invocation.
if (_logger.isLoggable(TRACE_LEVEL)) {
logTraceInfo(inv, sc, "Calling delayed afterCompletion");
}
callEjbAfterCompletion(sc, sc.getCompletedTxStatus());
}
if (sc.getState() != BeanState.DESTROYED) {
// callEjbAfterCompletion could make state as DESTROYED
sc.setState(BeanState.READY);
handleEndOfMethodCheckpoint(sc, inv);
}
}
if ((sc.getState() != BeanState.DESTROYED) && isHAEnabled) {
syncClientVersion(inv, sc);
}
} else {
if ((sc.getState() != BeanState.DESTROYED) && isHAEnabled) {
syncClientVersion(inv, sc);
}
sc.setState(BeanState.INCOMPLETE_TX);
if (_logger.isLoggable(TRACE_LEVEL)) {
logTraceInfo(inv, sc, "Marking state == INCOMPLETE_TX");
}
}
} catch (SystemException ex) {
throw new EJBException(ex);
} finally {
releaseSFSBSerializedLock(inv, sc);
}
}
Aggregations