3 Replies Latest reply on Apr 17, 2002 5:46 PM by Adam Young

    JNDI Lookup / Struts / EJB

    Derek Newbie


      I am running Tomcat and JBoss from the bundled download, that is i have a directory with both in.
      i have to start them separately, jboss then tomcat and all is well.
      but, for some reason the Struts Action class can no longer find the EJB, when i try and locate the one and only session bean, i get the following stack trace...


      BaseEventResult Constructor
      LoginAction : Getting Home Reference
      EJBUtils - getBaseHome()
      Created InitialContext JNDI, LOOKING UP EJBEAN...

      here's where things go wrong...

      Received throwable with Message: jnp
      getBaseHome() NamingExceptionjavax.naming.ServiceUnavailableException: jnp. Roo
      t exception is java.net.UnknownHostException: jnp
      at java.net.InetAddress.getAllByName0(InetAddress.java:571)
      at java.net.InetAddress.getAllByName0(InetAddress.java:540)
      at java.net.InetAddress.getByName(InetAddress.java:449)
      at java.net.Socket.(Socket.java:100)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:102)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:776)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:340)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)
      at javax.naming.InitialContext.lookup(InitialContext.java:350)
      at com.deloitte.utils.EJBUtil.getBaseHome(EJBUtil.java:52)
      at com.deloitte.web.LoginAction.handleEvent(LoginAction.java:119)
      at com.deloitte.web.LoginAction.perform(LoginAction.java:68)
      at org.apache.struts.action.ActionServlet.processActionPerform(ActionSer
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:158
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)


      I have a jboss.xml file whih binds the TestEJB to TestEJB,

      I have the following JNDI properties set up:

      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.put(Context.PROVIDER_URL, "jnp://localhost:1099");

      return new javax.naming.InitialContext(p);

      it was working, but now its not, i have tried all i can really think of.


      i would greatly appreciate some help or ideas.

        • 1. Re: JNDI Lookup / Struts / EJB
          Adrian Brock Master

          Are you sure the jndi.properties are as shown?

          Tomcat seems to think the url is just "jnp"?

          Which bundle did you download, I can't tell from the


          • 2. Re: JNDI Lookup / Struts / EJB
            Derek Newbie

            Hi Adrian,

            just after i posted the message the problem resolved, but unfortunately i do not know why and i cannot seem to replicate it.

            i understand that the integration between tomcat and jboss is not as tight as it could be and perhaps this is the problem.
            it seems that the problem was resolved once i restarted either jboss or tomcat.

            the only thing that i changed last was the lookUp(). i forced it to look up a bean name that i knew did not exist. consequently i received a 'bean not bound' exception. then, after this i changed the name back to the correct bean name (redeployed the ejb 'jar' and webapp 'war') and bingo it found the bean and the rest of the code executed as expected.

            i dont like these kind of errors/situations.

            thanks again

            • 3. Re: JNDI Lookup / Struts / EJB
              Adam Young Newbie

              Are you running the integrated tomcat-jboss setup, or are you running them in separate JVMs? You'll lose the local marshalling in separate JVMS (I believe)