Search in sources :

Example 61 with EJBException

use of javax.ejb.EJBException in project Payara by payara.

the class AsynchronousTask method createEJBObjectImpl.

/**
 * This is called from the generated "HelloEJBHomeImpl" create method
 * via EJBHomeImpl.createEJBObject.
 * Note: for stateful beans, the HelloEJBHomeImpl.create calls
 * ejbCreate on the new bean after createEJBObject() returns.
 * Return the EJBObject for the bean.
 */
protected EJBObjectImpl createEJBObjectImpl() throws CreateException, RemoteException {
    try {
        SessionContextImpl context = createBeanInstance();
        EJBObjectImpl ejbObjImpl = createEJBObjectImpl(context);
        afterInstanceCreation(context);
        return ejbObjImpl;
    } catch (Exception ex) {
        _logger.log(Level.WARNING, CREATE_EJBOBJECT_EXCEPTION, new Object[] { ejbDescriptor.getName(), ex });
        if (ex instanceof EJBException)
            throw (EJBException) ex;
        else {
            CreateException ce = new CreateException("ERROR creating stateful SessionBean");
            ce.initCause(ex);
            throw ce;
        }
    }
}
Also used : EJBObject(javax.ejb.EJBObject) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException) IllegalLoopbackException(javax.ejb.IllegalLoopbackException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoveException(javax.ejb.RemoveException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) SystemException(javax.transaction.SystemException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException)

Example 62 with EJBException

use of javax.ejb.EJBException in project Payara by payara.

the class AsynchronousTask method createEJBLocalObjectImpl.

/**
 * This is called from the generated "HelloEJBLocalHomeImpl" create method
 * via EJBLocalHomeImpl.createEJBObject.
 * Note: for stateful beans, the HelloEJBLocalHomeImpl.create calls
 * ejbCreate on the new bean after createEJBLocalObjectImpl() returns.
 * Return the EJBLocalObject for the bean.
 */
protected EJBLocalObjectImpl createEJBLocalObjectImpl() throws CreateException {
    try {
        SessionContextImpl context = createBeanInstance();
        EJBLocalObjectImpl localObjImpl = createEJBLocalObjectImpl(context);
        afterInstanceCreation(context);
        return localObjImpl;
    } catch (Exception ex) {
        _logger.log(Level.WARNING, CREATE_EJBLOCALOBJECT_EXCEPTION, new Object[] { ejbDescriptor.getName(), ex });
        if (ex instanceof EJBException)
            throw (EJBException) ex;
        else {
            CreateException ce = new CreateException("ERROR creating stateful SessionBean");
            ce.initCause(ex);
            throw ce;
        }
    }
}
Also used : EJBObject(javax.ejb.EJBObject) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException) IllegalLoopbackException(javax.ejb.IllegalLoopbackException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoveException(javax.ejb.RemoveException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) SystemException(javax.transaction.SystemException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException)

Example 63 with EJBException

use of javax.ejb.EJBException in project Payara by payara.

the class AsynchronousTask method getEJBLocalBusinessObjectImpl.

EJBLocalObjectImpl getEJBLocalBusinessObjectImpl(Object sessionKey) {
    // Create an EJBLocalObject reference which
    // is *not* associated with a SessionContext.  That way, the
    // session bean context lookup will be done lazily whenever
    // the reference is actually accessed.  This avoids I/O in the
    // case that the reference points to a passivated session bean.
    // It's also consistent with the deserialization approach used
    // throughout the container.  e.g. a timer reference is deserialized
    // from its handle without checking it against the timer database.
    EJBLocalObjectImpl localBusinessObjImpl;
    try {
        localBusinessObjImpl = instantiateEJBLocalBusinessObjectImpl();
        localBusinessObjImpl.setKey(sessionKey);
    } catch (Exception ex) {
        EJBException ejbEx = new EJBException();
        ejbEx.initCause(ex);
        throw ejbEx;
    }
    return localBusinessObjImpl;
}
Also used : EJBException(javax.ejb.EJBException) IllegalLoopbackException(javax.ejb.IllegalLoopbackException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoveException(javax.ejb.RemoveException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) SystemException(javax.transaction.SystemException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException)

Example 64 with EJBException

use of javax.ejb.EJBException in project Payara by payara.

the class AsynchronousTask method createEJBLocalBusinessObjectImpl.

/**
 * Internal creation event for Local Business view of SFSB
 */
EJBLocalObjectImpl createEJBLocalBusinessObjectImpl(boolean localBeanView) throws CreateException {
    try {
        SessionContextImpl context = createBeanInstance();
        EJBLocalObjectImpl localBusinessObjImpl = localBeanView ? createOptionalEJBLocalBusinessObjectImpl(context) : createEJBLocalBusinessObjectImpl(context);
        afterInstanceCreation(context);
        return localBusinessObjImpl;
    } catch (Exception ex) {
        _logger.log(Level.WARNING, CREATE_EJBLOCALOBJECT_EXCEPTION, new Object[] { ejbDescriptor.getName(), ex });
        if (ex instanceof EJBException)
            throw (EJBException) ex;
        else {
            CreateException ce = new CreateException("ERROR creating stateful SessionBean");
            ce.initCause(ex);
            throw ce;
        }
    }
}
Also used : EJBObject(javax.ejb.EJBObject) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException) IllegalLoopbackException(javax.ejb.IllegalLoopbackException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoveException(javax.ejb.RemoveException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) SystemException(javax.transaction.SystemException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException)

Example 65 with EJBException

use of javax.ejb.EJBException in project Payara by payara.

the class AsynchronousTask method validateEMForClientTx.

@Override
protected void validateEMForClientTx(EjbInvocation inv, JavaEETransaction clientJ2EETx) throws EJBException {
    SessionContextImpl sessionCtx = (SessionContextImpl) inv.context;
    Map<EntityManagerFactory, PhysicalEntityManagerWrapper> entityManagerMap = sessionCtx.getExtendedEntityManagerMap();
    for (Map.Entry<EntityManagerFactory, PhysicalEntityManagerWrapper> entry : entityManagerMap.entrySet()) {
        EntityManagerFactory emf = entry.getKey();
        // Extended persistence context for the propagated transaction.
        if (clientJ2EETx.getTxEntityManagerResource(emf) != null) {
            throw new EJBException("There is an active transactional persistence context for the same EntityManagerFactory as the current stateful session bean's extended persistence context");
        }
        // Now see if there's already a *different* extended
        // persistence context within this transaction for the
        // same EntityManagerFactory.
        PhysicalEntityManagerWrapper physicalEM = (PhysicalEntityManagerWrapper) clientJ2EETx.getExtendedEntityManagerResource(emf);
        if ((physicalEM != null) && entry.getValue().getEM() != physicalEM.getEM()) {
            throw new EJBException("Detected two different extended persistence contexts for the same EntityManagerFactory within a transaction");
        }
    }
}
Also used : PhysicalEntityManagerWrapper(com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper) EntityManagerFactory(javax.persistence.EntityManagerFactory) EJBException(javax.ejb.EJBException) Map(java.util.Map) HashMap(java.util.HashMap)

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