2 Replies Latest reply on Dec 27, 2002 1:06 AM by davej

    Remote InitialContext.lookup() returns null; local succeeds

    davej

      Hi,

      I'm having trouble doing remote lookup()s with JBoss 3.0.4's JNP service. The code in question succeeds for a jnp:/localhost:1099/ URL, but the same lookup() returns null with jnp:/hostname:1099/ (where hostname is where the JBoss server is running).

      Here's the code snippet:

      System.out.println("hostname=" + hostname + ", URL=" + jndiURL
      + ", requests=" + EchoServicesClient.numRequests + ", threads=" + numThreads);

      Properties env = new Properties();
      env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      env.setProperty(Context.PROVIDER_URL, jndiURL);
      env.setProperty(Context.URL_PKG_PREFIXES,
      JNP_PKG_PREFIXES);
      Context ctx = new InitialContext(env);
      System.err.println("Got new InitialContext() of class " + ctx.getClass());

      Object lkup = ctx.lookup("com.foodiedave.ejb.echo.EchoServices");
      if (null == lkup) {
      System.err.println("Can't lookup() EchoServicesHome interface");
      System.exit(1);
      }

      ...and here's the execution output:

      meekrob: java com.foodiedave.ejb.echo.client.EchoServicesClient DaveAthlonRH 10 10
      hostname=DaveAthlonRH, URL=jnp://DaveAthlonRH:1099/, requests=10, threads=10
      Got new InitialContext() of class class javax.naming.InitialContext
      Can't lookup() EchoServicesHome interface


      So, anyone have any ideas as to why this fails only on a remote lookup()?

      Thanks,
      --dave

        • 1. Re: Remote InitialContext.lookup() returns null; local succe

          /etc/hosts

          remove the hostname mapping to 127.0.0.1

          Regards,
          Adrian

          • 2. Re: Remote InitialContext.lookup() returns null; local succe
            davej

            Thanks for the suggestion. Sorry for the slow response -- I've been outta town and away from my dev sandbox.

            I found another, earlier thread (" Remote EJB Client Connection Refused - ConnectException") on what appears to be this same problem, with a slightly different symptom:

            "After some digging, we found that the problem is that the correct host name is not being bound by the RMI Server in JBoss. There appear to be two solutions:
            1. set the 'java.rmi.server.hostname' environment variable to the hosts fully qualified name or IP address in the run.sh / run.bat startup script.
            2. set the name of the localhost in the /etc/hosts file to be the fully qualified name or IP address."

            #2 sounds a lot like your proposed workaround, which does indeed address the symptom. But I think I prefer workaround #1 for "cleanliness" sake. At least it isolates the fix to the rough scope of the source of the trouble.

            Which leads me to a couple of questions (which may go unanswered in this forum...?):

            - Is there something to be done in the Jboss code which could alleviate the need for this workaround?
            - Has it been done already, or scheduled to be done? (i.e., is it a reported bug?)

            Being a newbie, I'm not sure precisely where to look for these answers around here...pointers?

            Thanks,
            --dave