Search in sources :

Example 46 with EJBException

use of javax.ejb.EJBException in project tomee by apache.

the class RmiIiopCmp2Bean method returnHandle.

public Handle returnHandle() {
    Handle data = null;
    try {
        final InitialContext ctx = new InitialContext();
        final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
        final EncCmpObject object = home.create("Test03 CmpBean");
        data = object.getHandle();
    } catch (final Exception e) {
        throw new EJBException(e);
    }
    return data;
}
Also used : EJBException(javax.ejb.EJBException) InitialContext(javax.naming.InitialContext) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException) Handle(javax.ejb.Handle)

Example 47 with EJBException

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

the class AbstractSingletonContainer method _getContext.

@Override
protected ComponentContext _getContext(EjbInvocation invocation) throws EJBException {
    checkInit();
    if (clusteredLookup.isClusteredEnabled()) {
        AbstractSessionContextImpl sessionContext = (AbstractSessionContextImpl) singletonCtx;
        try {
            invocationManager.preInvoke(invocation);
            invocation.context = sessionContext;
            sessionContext.setEJB(clusteredLookup.getClusteredSingletonMap().get(clusteredLookup.getClusteredSessionKey()));
            if (isJCDIEnabled()) {
                if (sessionContext.getJCDIInjectionContext() != null) {
                    sessionContext.getJCDIInjectionContext().cleanup(false);
                }
                sessionContext.setJCDIInjectionContext(_createJCDIInjectionContext(sessionContext, sessionContext.getEJB()));
            }
            if (sessionContext.getEJB() != null) {
                injectEjbInstance(sessionContext);
            }
        } catch (Exception ex) {
            throw new EJBException(ex);
        } finally {
            invocation.context = null;
            invocationManager.postInvoke(invocation);
        }
    }
    return singletonCtx;
}
Also used : NoSuchEJBException(javax.ejb.NoSuchEJBException) EJBException(javax.ejb.EJBException) NoSuchEJBException(javax.ejb.NoSuchEJBException) RemoveException(javax.ejb.RemoveException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException)

Example 48 with EJBException

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

the class SafeProperties method getJaccEjb.

/**
 * Called-back from security implementation through EjbInvocation
 * when a jacc policy provider wants an enterprise bean instance.
 */
public Object getJaccEjb(EjbInvocation inv) {
    Object bean = null;
    // Remote , Local, and ServiceEndpoint interfaces.
    if (((inv.invocationInfo != null) && inv.invocationInfo.isBusinessMethod) || inv.isWebService) {
        // twice within the same authorization decision.
        if (inv.context == null) {
            try {
                inv.context = getContext(inv);
                bean = inv.context.getEJB();
            // NOTE : inv.ejb is not set here.  Post-invoke logic for
            // BaseContainer and webservices uses the fact that
            // inv.ejb is non-null as an indication that that
            // BaseContainer.preInvoke() proceeded past a certain
            // point, which affects which cleanup needs to be
            // performed.  It would be better to have explicit
            // state in the invocation that says which cleanup
            // steps are necessary(e.g. for invocationMgr.postInvoke
            // , postInvokeTx, etc) but I'm keeping the logic the
            // same for now.   BaseContainer.authorize() will
            // explicitly handle the case where a context was
            // created as a result of this call and the
            // authorization failed, which means the context needs
            // be released.
            } catch (EJBException e) {
                _logger.log(Level.WARNING, CONTEXT_FAILURE_JACC, logParams[0]);
                _logger.log(Level.WARNING, "", e);
            }
        } else {
            bean = inv.context.getEJB();
        }
    }
    return bean;
}
Also used : EJBLocalObject(javax.ejb.EJBLocalObject) EJBObject(javax.ejb.EJBObject) EJBException(javax.ejb.EJBException) NoSuchEJBException(javax.ejb.NoSuchEJBException)

Example 49 with EJBException

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

the class SafeProperties method doAfterBegin.

// Implementation of Container method.
// Called from UserTransactionImpl after the EJB started a Tx,
// for TX_BEAN_MANAGED EJBs only.
public final void doAfterBegin(ComponentInvocation ci) {
    EjbInvocation inv = (EjbInvocation) ci;
    try {
        // Associate the context with tx so that on subsequent
        // invocations with the same tx, we can do the appropriate
        // tx.resume etc.
        EJBContextImpl sc = (EJBContextImpl) inv.context;
        Transaction tx = transactionManager.getTransaction();
        if (!isSingleton) {
            sc.setTransaction(tx);
        }
        // Register Synchronization with TM so that we can
        // dissociate the context from tx in afterCompletion
        ejbContainerUtilImpl.getContainerSync(tx).addBean(sc);
        enlistExtendedEntityManagers(sc);
    // Dont call container.afterBegin() because
    // TX_BEAN_MANAGED EntityBeans are not allowed,
    // and SessionSync calls on TX_BEAN_MANAGED SessionBeans
    // are not allowed.
    } catch (SystemException ex) {
        throw new EJBException(ex);
    } catch (RollbackException ex) {
        throw new EJBException(ex);
    } catch (IllegalStateException ex) {
        throw new EJBException(ex);
    }
}
Also used : Transaction(javax.transaction.Transaction) UserTransaction(javax.transaction.UserTransaction) JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) SystemException(javax.transaction.SystemException) EJBException(javax.ejb.EJBException) NoSuchEJBException(javax.ejb.NoSuchEJBException) RollbackException(javax.transaction.RollbackException)

Example 50 with EJBException

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

the class SafeProperties method mapRemoteException.

private Throwable mapRemoteException(EjbInvocation inv) {
    Throwable originalException = inv.exception;
    Throwable mappedException = originalException;
    // 2.x client view.
    if (inv.invocationInfo.isAsynchronous()) {
        if (java.rmi.Remote.class.isAssignableFrom(inv.clientInterface)) {
            mappedException = protocolMgr.mapException(originalException);
            if (mappedException == originalException) {
                if (originalException instanceof EJBException) {
                    mappedException = new RemoteException(originalException.getMessage(), originalException);
                }
            }
        } else {
            mappedException = mapLocal3xException(originalException);
        }
    } else {
        // Synchronous invocation.  First let the protocol manager perform
        // its mapping.
        mappedException = protocolMgr.mapException(originalException);
        // If no mapping happened
        if (mappedException == originalException) {
            if (inv.isBusinessInterface) {
                // client can unwrap it and ensure that the client receives EJBException.
                if (originalException instanceof EJBException) {
                    mappedException = new InternalEJBContainerException(originalException.getMessage(), originalException);
                }
            } else {
                if (originalException instanceof EJBException) {
                    mappedException = new RemoteException(originalException.getMessage(), originalException);
                }
            }
        }
    }
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Mapped original remote exception " + originalException + " to exception " + mappedException + " for " + inv);
    }
    return mappedException;
}
Also used : EJBException(javax.ejb.EJBException) NoSuchEJBException(javax.ejb.NoSuchEJBException) RemoteException(java.rmi.RemoteException)

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