Search in sources :

Example 56 with EJBException

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_);
}
Also used : EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException)

Example 57 with EJBException

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;
}
Also used : Timer(javax.ejb.Timer) Iterator(java.util.Iterator) Collection(java.util.Collection) EJBException(javax.ejb.EJBException) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException) FinderException(javax.ejb.FinderException) HashSet(java.util.HashSet)

Example 58 with EJBException

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);
    }
}
Also used : NoSuchEJBException(javax.ejb.NoSuchEJBException) Container(com.sun.ejb.Container) NoSuchEJBException(javax.ejb.NoSuchEJBException) EJBException(javax.ejb.EJBException) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Example 59 with EJBException

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;
}
Also used : EJBException(javax.ejb.EJBException)

Example 60 with EJBException

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);
    }
}
Also used : InvocationInfo(com.sun.ejb.InvocationInfo) JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) EjbRemovalInfo(org.glassfish.ejb.deployment.descriptor.EjbRemovalInfo) EJBException(javax.ejb.EJBException)

Aggregations

EJBException (javax.ejb.EJBException)169 CreateException (javax.ejb.CreateException)51 RemoteException (java.rmi.RemoteException)45 RemoveException (javax.ejb.RemoveException)40 InitialContext (javax.naming.InitialContext)40 NoSuchObjectLocalException (javax.ejb.NoSuchObjectLocalException)37 SystemException (javax.transaction.SystemException)37 FinderException (javax.ejb.FinderException)30 InvocationTargetException (java.lang.reflect.InvocationTargetException)24 OpenEJBException (org.apache.openejb.OpenEJBException)24 EJBObject (javax.ejb.EJBObject)18 NoSuchEntityException (javax.ejb.NoSuchEntityException)17 IOException (java.io.IOException)16 Test (org.junit.Test)16 EjbInvocation (com.sun.ejb.EjbInvocation)14 ConcurrentAccessException (javax.ejb.ConcurrentAccessException)14 IllegalLoopbackException (javax.ejb.IllegalLoopbackException)14 NamingException (javax.naming.NamingException)14 NotSerializableException (java.io.NotSerializableException)13 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)13