Search in sources :

Example 11 with SessionContext

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

the class EncStatefulBean method lookupSessionContext.

public void lookupSessionContext() throws TestFailureException {
    try {
        try {
            final InitialContext ctx = new InitialContext();
            Assert.assertNotNull("The InitialContext is null", ctx);
            // lookup in enc
            final SessionContext sctx = (SessionContext) ctx.lookup("java:comp/env/sessioncontext");
            Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx);
            // lookup using global name
            final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
            Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx);
            // verify context was set via legacy set method
            Assert.assertNotNull("The SessionContext is null from setter method", ejbContext);
        } catch (final Exception e) {
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
Also used : EJBContext(javax.ejb.EJBContext) SessionContext(javax.ejb.SessionContext) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) InitialContext(javax.naming.InitialContext) JMSException(javax.jms.JMSException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) TestFailureException(org.apache.openejb.test.TestFailureException) CreateException(javax.ejb.CreateException)

Aggregations

EJBContext (javax.ejb.EJBContext)11 SessionContext (javax.ejb.SessionContext)11 RemoteException (java.rmi.RemoteException)10 EJBException (javax.ejb.EJBException)10 InitialContext (javax.naming.InitialContext)9 AssertionFailedError (junit.framework.AssertionFailedError)9 TestFailureException (org.apache.openejb.test.TestFailureException)9 JMSException (javax.jms.JMSException)7 NamingException (javax.naming.NamingException)4 Method (java.lang.reflect.Method)2 NoSuchObjectException (java.rmi.NoSuchObjectException)2 CreateException (javax.ejb.CreateException)2 EJBAccessException (javax.ejb.EJBAccessException)2 RemoveException (javax.ejb.RemoveException)2 MBeanServer (javax.management.MBeanServer)2 ObjectName (javax.management.ObjectName)2 Context (javax.naming.Context)2 ApplicationException (org.apache.openejb.ApplicationException)2 BeanContext (org.apache.openejb.BeanContext)2 InvalidateReferenceException (org.apache.openejb.InvalidateReferenceException)2