7 Replies Latest reply on Oct 2, 2007 7:00 PM by kosiakk

    Having problems looking up a Seam component in the JNDI ENC

    zzzz8

      I'm running Seam in Tomcat (EJB 3 embedded) and my client program cannot perform the lookup. I'm not sure if I'm missing something in my configuration files. My jndi.properties has the following (which is the default content in the jndi.properties file given in the Seam examples):

      java.naming.factory.initial org.jnp.interfaces.LocalOnlyContextFactory
      java.naming.factory.url.pkgs org.jboss.naming:org.jnp.interfaces


      My stateless session bean is defined like this:

      @Name("TestConnection")
      @Stateless
      public final class TestConnectionBean implements TestConnectionLocal {
      ...
      }


      In my client code which is used to lookup the Seam component, I have the following:

      TestConnectionLocal connection = null;
      try {
       InitialContext ctx = new InitialContext();
       connection = (TestConnectionLocal) ctx.lookup("java:comp/env/ejb/TestConnectionBean/local");
      ....
      }


      When I try invoking it from my client code, I get the typical NameNotFoundException error:

      javax.naming.NameNotFoundException: Name TestConnectionBean is not bound in this Context


      I've noticed the following on startup on the Tomcat console:

      INFO 30-09 18:54:08,523 (Component.java:<init>:217) -Component: TestConnection, scope: STATELESS, type: STATELESS_SESSION_BEAN, class: test.TestConnectionBean, JNDI: TestConnectionBean/local


      I've tried a couple of different contexts without success:

      java:comp/env/TestConnectionBean/local
      TestConnectionBean/local
      etc...

      The Tomcat JMX console (and I'm also using MC4J) don't seem to show the Seam components anywhere... What am I doing wrong? Thanks!

        • 1. Re: Having problems looking up a Seam component in the JNDI
          pmuir

          I'm pretty sure Seam components aren't registered in JNDI, EJB3 session beans are though - The JNDI name in the Seam startup refers to this. I would suggest asking on the EJB3 forum about JNDI lookup of EJB3 session beans.

          • 2. Re: Having problems looking up a Seam component in the JNDI
            c_inconnu

            Hi,

            This is an old thread but i got the exact same problem. Have you managed to get this working ?

            I must say that i'm using Maven2. The following works in JBoss AS but not in the microcontainer :

            @Local
            public interface Authenticator
            {
             boolean authenticate();
            }
            


            and

            @Name("authenticator")
            @Stateless public class AuthenticatorAction
             implements Authenticator
            { ... }
            


            and got

            ERROR 2007-04-13 16:58:41,187 (SeamLoginModule.java:108) - Error invoking login method
            org.jboss.seam.InstantiationException: Could not instantiate Seam component: authenticator
             at org.jboss.seam.Component.newInstance(Component.java:1740)
             at org.jboss.seam.Component.getInstance(Component.java:1643)
             at org.jboss.seam.Component.getInstance(Component.java:1610)
             at org.jboss.seam.Component.getInstance(Component.java:1604)
             at org.jboss.seam.jsf.SeamELResolver.getValue(SeamELResolver.java:49)
             at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:135)
             at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
             at com.sun.el.parser.AstValue.getTarget(AstValue.java:41)
             at com.sun.el.parser.AstValue.invoke(AstValue.java:126)
             at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
             at org.jboss.seam.util.UnifiedELMethodBinding.invoke(UnifiedELMethodBinding.java:36)
             at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
             at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
             at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:148)
             at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:104)
             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:247)
             at org.jboss.seam.security.Identity.authenticate(Identity.java:240)
             at org.jboss.seam.security.Identity.login(Identity.java:170)
             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 com.sun.el.parser.AstValue.invoke(AstValue.java:130)
             at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
             at org.jboss.seam.util.UnifiedELMethodBinding.invoke(UnifiedELMethodBinding.java:36)
             at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
             at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
             at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
             at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
             at org.jboss.seam.mock.SeamTest$Request.invokeMethod(SeamTest.java:401)
             at org.jboss.seam.example.booking.LoginTest$2.invokeApplication(LoginTest.java:76)
             at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:489)
             at org.jboss.seam.example.booking.LoginTest.testLogin(LoginTest.java:60)
             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.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
             at org.testng.internal.Invoker.invokeMethod(Invoker.java:411)
             at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:785)
             at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:114)
             at org.testng.TestRunner.privateRun(TestRunner.java:693)
             at org.testng.TestRunner.run(TestRunner.java:574)
             at org.testng.SuiteRunner.privateRun(SuiteRunner.java:241)
             at org.testng.SuiteRunner.run(SuiteRunner.java:145)
             at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901)
             at org.testng.TestNG.runSuitesLocally(TestNG.java:863)
             at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeTestNG(TestNGDirectoryTestSuite.java:195)
             at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:133)
             at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
             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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
             at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
            Caused by: javax.naming.NameNotFoundException: AuthenticatorAction not bound
             at org.jnp.server.NamingServer.getBinding(NamingServer.java:516)
             at org.jnp.server.NamingServer.getBinding(NamingServer.java:524)
             at org.jnp.server.NamingServer.getObject(NamingServer.java:530)
             at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
             at javax.naming.InitialContext.lookup(InitialContext.java:392)
             at org.jboss.seam.Component.instantiateSessionBean(Component.java:1107)
             at org.jboss.seam.Component.instantiate(Component.java:1093)
             at org.jboss.seam.Component.newInstance(Component.java:1736)
             ... 65 more
            


            Although i also got :

             INFO 2007-04-13 16:58:34,703 (Component.java:245) - Component: authenticator, scope: STATELESS, type: STATELESS_SESSION_BEAN, class: xxx.actions.AuthenticatorAction, JNDI: AuthenticatorAction/local
            


            When i look into jndi from my test class
            InitialContext context = new InitialContext();
            NamingEnumeration<NameClassPair> enumeration = context.list("java:/");
            ...
            


            i got only

            UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction
            impDatasource: org.jboss.resource.adapter.jdbc.WrapperDataSource
            TransactionManager: org.jboss.tm.TxManager
            


            I tried so much things ... Thanks

            David

            • 3. Re: Having problems looking up a Seam component in the JNDI
              zzzz8

              I asked the same question in the EJB3 forum a while back and I didn't get a reply there either. I did not make any progress on this issue (and abandoned it). So unfortunately, I can't offer much help...

              • 4. Re: Having problems looking up a Seam component in the JNDI
                c_inconnu

                 

                "zzzz8" wrote:
                I asked the same question in the EJB3 forum a while back and I didn't get a reply there either. I did not make any progress on this issue (and abandoned it). So unfortunately, I can't offer much help...


                Thanks...

                Anyone from the Seam team ? Please ?

                • 5. Re: Having problems looking up a Seam component in the JNDI
                  christian.bauer

                   


                  java:comp/env/ejb/TestConnectionBean/local


                  This just not the right JNDI lookup to get a remote EJB handle. I'm not sure what the right lookup is (definitely not with an ENC prefix) and if the old E-EJB3 container even supports remote JNDI/remote EJBs. I don't think it does.

                  All of this has not much to do with Seam, though.


                  • 6. Re: Having problems looking up a Seam component in the JNDI
                    christian.bauer

                    The newer Embedded JBoss5 container supports remote EJB/JNDI by the way, check the wiki. Now we only need a release of this and someone who will update all the Seam examples and the testing framework :)

                    • 7. Re: Having problems looking up a Seam component in the JNDI

                      @Local interface is redundant now!

                      just write

                      @Name("authenticator")
                      public class AuthenticatorAction
                      { ... }
                      


                      and it will work after Seam2 integration =)