7 Replies Latest reply on Jul 23, 2002 3:32 AM by Dave

    NameNotFoundException using Struts with JBoss 3.0

    Dave Newbie

      Hi,

      I'm running JBoss 3.0 with Tomcat 4.0.3 integrated.
      I have created a simple Struts application which makes a call from inside an action to a session bean.
      But I keep getting the following error :

      14:55:33,046 INFO [Engine] action: Creating new Action instance
      14:55:33,496 ERROR [STDERR] NAMING EXCEPTION OCCURED
      14:55:33,496 ERROR [STDERR] javax.naming.NameNotFoundException: ea not bound
      14:55:33,496 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(Naming
      Server.java:495)
      14:55:33,496 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(Naming
      Server.java:503)
      14:55:33,496 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingS
      erver.java:509)
      14:55:33,496 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServ
      er.java:253)
      14:55:33,496 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(Namin
      gContext.java:445)
      14:55:33,496 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(Namin
      gContext.java:429)
      14:55:33,496 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialCon
      text.java:347)
      14:55:33,496 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(Namin
      gContext.java:522)
      14:55:33,496 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(Namin
      gContext.java:558)
      14:55:33,496 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(Namin
      gContext.java:429)
      14:55:33,496 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialCon
      text.java:347)
      14:55:33,496 ERROR [STDERR] at com.presscollection.eassist.web.actions.ViewA
      rticleListAction.performAction(ViewArticleListAction.java:61)
      14:55:33,496 ERROR [STDERR] at com.presscollection.eassist.web.actions.EAMai
      nAction.perform(EAMainAction.java:50)

      My configuration files look like this :
      ejb-jar.xml
      - ejb-name = PageFacadeEJB

      jboss.xml
      - ejb-name = PageFacadeEJB
      - jndi-name = ea/PageFacade

      web.xml
      - ejb-ref-name = ejb/PageFacadeEJB

      jboss-web.xml
      - ejb-ref-name = ejb/PageFacadeEJB
      - jndi-name = ea/PageFacade

      The call i do to lookup the session bean is the following :
      jndiContext.lookup( "java:comp/env/ejb/PageFacadeEJB" );

      It looks like it can find the mapping in jboss-web.xml, but from there it doesn't find the ea mapping ...


      Please help me,
      Thnx,
      Dave

        • 1. Re: NameNotFoundException using Struts with JBoss 3.0
          Mikael Eriksson Novice

          When I try to do something similar I get a deployment exception when my ear is loaded (see last of message for a part of the stack trace).

          However, when I insert an ejb-link element into the web.xml

          -->
          <ejb-ref>
          EJB for Definitions
          <ejb-ref-name>ejb/DefinitionHandlerSL2</ejb-ref-name>
          ... omitted ...
          <ejb-link>DefinitionHandler</ejb-link>
          </ejb-ref>


          Where my ejb is named DefinitionHandler (and that is also its JNDI name) things starts to work. I'm not sure if this is a bug in JBoss or if I am missing something. (Its JBoss 3.0.0 with Jetty).

          Regards
          Mikael

          ---- Stack Trace ----
          2002-07-19 20:49:42,601 INFO [org.jboss.jetty.Jetty] Extract jar:njar:file:/C:/server/jboss-3.0.0/server/first/tmp/deploy/server/first/deploy/firstjb.ear/64.firstjb.ear^/firstjb.war!/ to C:\DOCUME~1\mikael\LOKALA~1\Temp\Jetty__8080___firstjb\webapp
          2002-07-19 20:49:43,132 DEBUG [org.jboss.jetty.JBossWebApplicationContext#/firstjb] setting up ENC...
          2002-07-19 20:49:43,132 DEBUG [org.jboss.jetty.JettyService] AbstractWebContainer.parseWebAppDescriptors, Begin
          2002-07-19 20:49:43,132 DEBUG [org.jboss.jetty.JettyService] Creating ENC using ClassLoader: org.mortbay.http.ContextLoader(file:/C:/Documents and Settings/mikael/Lokala inställningar/TEMP/Jetty__8080___firstjb/webapp/WEB-INF/lib/struts.jar,file:/C:/Documents and Settings/mikael/Lokala inställningar/TEMP/Jetty__8080___firstjb/webapp/WEB-INF/classes/) / java.net.FactoryURLClassLoader@17e615
          2002-07-19 20:49:43,132 DEBUG [org.jboss.jetty.JettyService] ..java.net.FactoryURLClassLoader@17e615
          2002-07-19 20:49:43,132 DEBUG [org.jboss.jetty.JettyService] ..org.jboss.mx.loading.UnifiedClassLoader@251027{ url=njar:file:/C:/server/jboss-3.0.0/server/first/tmp/deploy/server/first/deploy/firstjb.ear/64.firstjb.ear^/firstjb.war }
          2002-07-19 20:49:43,132 DEBUG [org.jboss.jetty.JettyService] ..java.net.URLClassLoader@1a698a
          2002-07-19 20:49:43,132 DEBUG [org.jboss.jetty.JettyService] ..sun.misc.Launcher$AppClassLoader@71732b
          2002-07-19 20:49:43,132 DEBUG [org.jboss.jetty.JettyService] ..sun.misc.Launcher$ExtClassLoader@7fdcde
          2002-07-19 20:49:43,142 DEBUG [org.jboss.jetty.JettyService] Linked java:comp/UserTransaction to JNDI name: UserTransaction
          2002-07-19 20:49:43,142 DEBUG [org.jboss.jetty.JettyService] addEnvEntries
          2002-07-19 20:49:43,142 DEBUG [org.jboss.jetty.JettyService] linkResourceEnvRefs
          2002-07-19 20:49:43,142 DEBUG [org.jboss.jetty.JettyService] linkResourceRefs
          2002-07-19 20:49:43,142 DEBUG [org.jboss.jetty.JettyService] linkEjbRefs
          2002-07-19 20:49:43,142 ERROR [org.jboss.deployment.MainDeployer] could not start deployment: njar:file:/C:/server/jboss-3.0.0/server/first/tmp/deploy/server/first/deploy/firstjb.ear/64.firstjb.ear^/firstjb.war
          org.jboss.deployment.DeploymentException: ejb-ref: ejb/DefinitionHandlerSL2, no ejb-link match, use jndi-name in jboss-web.xml; - nested throwable: (javax.naming.NamingException: ejb-ref: ejb/DefinitionHandlerSL2, no ejb-link match, use jndi-name in jboss-web.xml)
          at org.jboss.jetty.Jetty.deploy(Jetty.java:423)
          at org.jboss.jetty.JettyService.performDeploy(JettyService.java:244)

          • 2. Re: NameNotFoundException using Struts with JBoss 3.0
            Mikael Eriksson Novice

            *sighs*

            I must have been doing something stupid before.

            When I went on exploring, and set a jndi-name for the ejb (first/DefinitionHandler) things started working even without and ejb-link. I probably had some spelling error before or something like that.

            But anyway, since your problem seems to be that it cannot find the ea subcontext, have you checked the JMX view (on port 8082) to see if your ejb has been deployed, and what JNDI name it have been given?

            Regards

            • 3. Re: NameNotFoundException using Struts with JBoss 3.0
              Dave Newbie

              I can see that my application is deployed.
              -> there is a link under jboss.management.single

              but where can you see the jndi name??

              I also want to know which string you use to lookup your bean? Do you use java:comp/env/ejb/beanName ?

              regards

              • 4. Re: NameNotFoundException using Struts with JBoss 3.0
                Dave Newbie

                There's something else I wanted to know :

                where do you put your jndi.properties if you have a webapplication deployed under tomcat?
                and most important, what lines are in your jndi.properties?

                I also want to mention, that i can lookup my session bean from a test client program. I only receive this naming error when I try to lookup from my struts action class.

                • 5. Re: NameNotFoundException using Struts with JBoss 3.0
                  Dave Newbie

                  Problem update:

                  I can see my eassist.ear reference in the jboss.management.single, but if i goto link to 'view the values of Modules', my eassist.jar isn't there, and I think it has to be there, not?
                  So my jar isn't deployed i think. The war file on the otherhand is deployed because i'm able to call my jsp's and struts actions.

                  So what can be the problem? I'm not getting any errors during deployment time...

                  Thanks in advance

                  • 6. Re: NameNotFoundException using Struts with JBoss 3.0
                    Mikael Eriksson Novice

                    > I can see that my application is deployed.
                    > -> there is a link under jboss.management.single
                    >
                    > but where can you see the jndi name??

                    In the section jboss.j2ee you should see
                    service=EJB,jndiName=<your_jndi_name>

                    >
                    > I also want to know which string you use to lookup
                    > your bean? Do you use java:comp/env/ejb/beanName ?

                    Yes,

                    My lookup code:
                    InitialContext ctx = new InitialContext();
                    Object defHomeObj = ctx.lookup("java:comp/env/ejb/DefinitionHandlerSL");

                    My web.xml:


                    <ejb-ref>
                    EJB for Definitions
                    <ejb-ref-name>ejb/DefinitionHandlerSL</ejb-ref-name>
                    <ejb-ref-type>Session</ejb-ref-type>
                    scot.firstjb.logic.definitionhandler.ejb.DefinitionHandlerHome
                    scot.firstjb.logic.definitionhandler.ejb.DefinitionHandler
                    </ejb-ref>

                    My jboss-web.xml
                    <ejb-ref>
                    <ejb-ref-name>ejb/DefinitionHandlerSL</ejb-ref-name>
                    <jndi-name>first/DefinitionHandler</jndi-name>
                    </ejb-ref>


                    My jboss.xml for the EJB:
                    <ejb-name>DefinitionHandler</ejb-name>
                    <jndi-name>first/DefinitionHandler</jndi-name>

                    • 7. Re: NameNotFoundException using Struts with JBoss 3.0
                      Dave Newbie

                      Thanks,

                      I got it all working now. After a long search I discovered that there was a little problem in my ant buildscript which resulted in a badly generated ejbjar file. So that's why my beans weren't deployed.

                      Again thanks for the replies ...