5 Replies Latest reply on Jul 29, 2008 4:38 PM by Pete Muir

    RMI EJB Remote Access "No active session context"  error - HELP!

    Andy Conn Newbie

      I apologize if this is too much of a newbie question, but I could REALLY USE SOME HELP!


      I would like to access a Stateless session bean from a stand-alone java program.  I have setup a simple test client:


      import java.util.Properties;
      import javax.naming.InitialContext;
      import com.bittware.parts.session.newsletter.IRmiTest;
      
      import conerp.core.Installation;
      
      
      public class Test {
      
           
           public static void main(String[] args) {
                
                
                // Get EJB object:
                try {
                     Properties properties = new Properties();
                     properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
                     properties.put("java.naming.provider.url","jnp://localhost:1099");
                     properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
                     InitialContext ctx = new InitialContext(properties);
      
                     // Get a TaskManager object               
                     System.out.println("Looking up using RmiTest/remote");
                     IRmiTest tester = (IRmiTest )ctx.lookup("partsdb/TestRmi/remote"); //("EntityApiBean/remote");
                     // LOOKUP IS SUCCESSFUL AND I CAN CALL LOGIN
                     tester .login("Andy Conn", "mypassword");
                     tester .test();
                     
                     System.out.println("Finished");
                } catch (Exception e){
                     e.printStackTrace();
                }
                
           }
           
      }
      



      My SLSB is pretty straightforward:


      package com.bittware.parts.session.newsletter;
      
      import javax.ejb.Stateless;
      import org.jboss.seam.security.Identity;
      
      @Stateless
      public class RmiTest implements IRmiTest {
           
      
         public boolean login(String username, String password)
         {
            // FAILS HERE on SetUserName:
            Identity.instance().setUsername(username);
            Identity.instance().setPassword(password);
            Identity.instance().login();
            return Identity.instance().isLoggedIn();
         }
           
      
      public void test(){
                
                  // Write a sample persistence record:
              System.out.println("I can do a call!");
            
                
                
           }
           
           
      
      }
      



      When I run my test program, the lookup is successful, the call can be made but the following error occurs in the login code at the Identity.instance().setUserName(); line:


      javax.ejb.EJBException: java.lang.IllegalStateException: No active session context
           at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
           at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
           at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:94)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
           at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
           at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
           at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
           at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
           at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
           at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
           at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
      Caused by: java.lang.IllegalStateException: No active session context
           at org.jboss.seam.security.Identity.instance(Identity.java:120)
           at com.bittware.parts.session.newsletter.RmiTest.login(RmiTest.java:24)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
           at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:101)
           at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
           at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
           at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:94)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
           at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
           at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
           at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
           at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
           at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
           at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
           at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
           at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
           at org.jboss.remoting.Client.invoke(Client.java:1634)
           at org.jboss.remoting.Client.invoke(Client.java:548)
           at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
           at $Proxy0.login(Unknown Source)
           at com.bittware.parts.test.newsletter.Test.main(LoadBlastTables.java:43)
           at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
           at $Proxy0.login(Unknown Source)
           at com.bittware.parts.test.newsletter.Test.main(Test.java:43)
      



      There seems to be something fundamentally wrong with what I am doing.  PLEASE point me on the right direction for this!

        • 2. Re: RMI EJB Remote Access "No active session context"  error - HELP!
          Andy Conn Newbie

          Great. I will try that.


          However, does this imply that the Seam security model has made me unable to access straight-up EJB session beans?


          Thanks.

          • 3. Re: RMI EJB Remote Access "No active session context"  error - HELP!
            Pete Muir Master

            You have a call to Identity.instance(), remove it, and your Bean will work. Or bootstrap the Seam lifecycle yourself.

            • 4. Re: RMI EJB Remote Access "No active session context"  error - HELP!
              Andy Conn Newbie

              Thanks Pete for your help so far.  Making my SLSB a SEAM component got me further.  However now it fails in the Identity.instance().login() call because in my Authenticator module there is no FacesContext:


              10:20:42,843 ERROR [SeamLoginModule] Error invoking login method
              javax.el.ELException: org.jboss.seam.RequiredException: @In attribute requires non-null value: authenticator.facesContext
                   at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:333)
                   at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:342)
                   at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
                   at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
                   at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                   at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:173)
                   at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:109)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:597)
                   at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
                   at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
                   at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
                   at java.security.AccessController.doPrivileged(Native Method)
                   at javax.security.auth.login.LoginContext.invokeCreatorPriv(LoginContext.java:703)
                   at javax.security.auth.login.LoginContext.login(LoginContext.java:575)
                   at org.jboss.seam.security.Identity.authenticate(Identity.java:259)
                   at org.jboss.seam.security.Identity.authenticate(Identity.java:248)
                   at org.jboss.seam.security.Identity.quietLogin(Identity.java:237)
                   at org.jboss.seam.security.Identity.isLoggedIn(Identity.java:145)
                   at org.jboss.seam.security.Identity.isLoggedIn(Identity.java:135)
                   at com.bittware.parts.session.newsletter.BlastPopulater.login(BlastPopulater.java:48)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:597)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                   at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                   at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                   at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:118)
                   at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:597)
                   at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                   at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
                   at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:94)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                   at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
                   at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
                   at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
                   at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
                   at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
                   at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
                   at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
              Caused by: org.jboss.seam.RequiredException: @In attribute requires non-null value: authenticator.facesContext
                   at org.jboss.seam.Component.getValueToInject(Component.java:2168)
                   at org.jboss.seam.Component.injectAttributes(Component.java:1598)
                   at org.jboss.seam.Component.inject(Component.java:1416)
                   at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                   at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
                   at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
                   at com.bittware.parts.session.Authenticator_$$_javassist_0.authenticate(Authenticator_$$_javassist_0.java)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:597)
                   at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
                   ... 74 more
              



              So it appears I may have to do some manual bootstapping regardless?  Can you point me in the right direction to get this going?


              Thanks - Andy

              • 5. Re: RMI EJB Remote Access "No active session context"  error - HELP!
                Pete Muir Master

                Inject with required=false and check whether it is not null before adding the message to it.