5 Replies Latest reply on Oct 9, 2003 12:57 PM by mafuertes

    JNDI problem- lookup for an ejb object: javax.naming.NamingE

    mafuertes

      Hi all,

      I get the following error when trying to lookup for an ejb object (calling the method javax.naming.InitialContext.lookup("EjbObject"), and I have been desperately looking to solve it for a long time with no success. The error I get from Tomcat is the following:

      75338 [Thread-5] INFO common.FrontControllerServlet - REQUEST RECEIVED
      75368 [Thread-5] INFO common.ServiceLocator - service name to lookup:ejb/BLController
      javax.naming.NameNotFoundException: El nombre ejb no este asociado a este contexto
      at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
      at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at esharing.service.common.ServiceLocator.getEJBHome(Unknown Source)
      at esharing.webtier.common.FrontControllerServlet.processRequest(Unknown
      Source)
      at esharing.webtier.common.FrontControllerServlet.doPost(Unknown Source)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)



      -The code that calls the EJB from a server page is the following:

      try {
      InitialContext ic = new InitialContext();
      Object objRef = ic.lookup("AccessControlManager");
      AccessControlManagerHome home = (AccessControlManagerHome)PortableRemoteObject.narrow(objRef, AccessControlManagerHome.class);
      accmanager = home.create();
      } catch (RemoteException ex) {
      System.out.println("Couldn't create AccessControlManager bean."+ ex.getMessage());
      } catch (CreateException ex) {
      System.out.println("Couldn't create AccessControlManager bean."+ ex.getMessage());
      } catch (NamingException ex) {
      System.out.println("Unable to lookup home: "+ "AccessControlManager "+ ex.getMessage());
      }

      I have tried with a changes in the web.xml file and jndi.properties file but it does not work anyway.
      Could you please help me?

      Thank you.

      Miguel

        • 1. Re: JNDI problem- lookup for an ejb object: javax.naming.Nam
          divine_comedy

          No 1 : Make sure that your jboss is up and running and that the jndi.properties are correct. Are you running Tomcat as part of JBoss ?

          No 2 : Make sure that the jndi name is in jboss.xml for your ejb.

          • 2. Re: JNDI problem- lookup for an ejb object: javax.naming.Nam
            mafuertes

            Thank you for your answer.

            I have the EJB in the jboss.xml file, and my jndi.properties (in C:\jboss-3.0.8_tomcat-4.1.24\server\default\conf) is:

            java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
            java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
            java.naming.provider.url=jnp://localhost:1099

            And I have the tomcat inside the Jboss.

            Any idea?

            Thanks.

            • 3. Re: JNDI problem- lookup for an ejb object: javax.naming.Nam
              darranl

              The original jndi.properties in 'C:\jboss-3.0.8_tomcat-4.1.24\server\default\conf'

              would have looked like

              java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
              java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
              # Do NOT uncomment this line as it causes in VM calls to go over
              # RMI!
              #java.naming.provider.url=localhost


              The line that says 'Do NOT uncomment this line as it causes in VM calls to go over RMI!' could also be phrased :-

              Do not remove the '#' in front of 'java.naming.provider.url'

              It could also be phrased

              Do not add a 'java.naming.provider.url' to this file.

              Or quite simply it could be phrased

              DO NOT EDIT THIS FILE

              Could someone get this file changed in CVS to make the comment clearer, I have lost count of the number of times messages have been posted relating to this file being edited.

              • 4. Re: JNDI problem- lookup for an ejb object: javax.naming.Nam

                Done here is the new version:

                # DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING
                #
                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

                Regards,
                Adrian

                • 5. Re: JNDI problem- lookup for an ejb object: javax.naming.Nam
                  mafuertes

                  Adrian,

                  Thank you very much.

                  I take it into account. It seems to work now after modifying it and some other changes.

                  Regards,
                  Miguel