12 Replies Latest reply on Dec 30, 2002 7:21 AM by Raphael M. Grochtmann

    JNDI lookup always returns null

    Rod Frey Newbie

      I'm clearly missing some configuration detail, but a scouring of the advanced docs and the forums hasn't given me a clue.

      My session EJBs seem to be getting registered correctly with the naming service. JNDIView reveals them living where I expect them to be: under the global namespace with names such as UserManager.

      I can browse the JBoss naming service using a number of JNDI browsing tools, such as the jndi browser from EJTools http://sourceforge.net/projects/ejtools.

      However, any attempt to connect to the naming server from a foreign host fails. There is no exception thrown: any lookup simply returns null. The JNDI browser mentioned above says the root context is null.

      Here's some sample code I'm running:

      java.util.Hashtable env = new java.util.Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "jnp://");
      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      env.put("jnp.socketFactory", "org.jnp.interfaces.TimedSocketFactory");
      env.put("jnp.timeout", "0");
      env.put("jnp.sotimeout", "0");
      Context context = new InitialContext(env);
      Object pmhObj = context.lookup(pmJndiName);
      System.out.println("3, " + pmhObj);
      PartnerManagerHome pmh = (PartnerManagerHome)javax.rmi.PortableRemoteObject.narrow(
      pmhObj, PartnerManagerHome.class);

      The code works perfectly if run on the same machine (from a different VM than JBoss). If run from a different machine, context.lookup(pmJndiName) returns null. No connection exception or anything like that is thrown.

      I'm using JBoss 3.0.4. There's no firewall running on the JBoss server.

      I'm stumped! I've tried mucking with hostnames, RMI settings (there was a error that required rmi hostname fiddling: this ain't it), PROVIDER_URL arguments, and various other hail-Mary solutions. Sleeping on it for a week hasn't worked either. =)

      Thanks in advance for any help.