3 Replies Latest reply on Nov 9, 2003 5:57 PM by jonlee

    Can't see JNDI on remote server

    vovan_onjava

      Hi.

      I need to access an EJB bean on remote JBOSS server.
      I do it this way:

      Hashtable hs = new Hashtable();
      hs.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      hs.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      hs.put(Context.PROVIDER_URL, "jnp://viktor.ld.ttu.ee:1099/");

      Context ctx = new InitialContext(hs);
      Object obj = ctx.lookup("PersonManagerEJB");
      .....

      For some reason I get this error:
      java.lang.NullPointerException

      Should I only change to localhost:1099 (where I'm running my local jboss) everything is fine.

      Could you give me any idea what's wrong with it.

      Thank you all in advance.
      Vladimir.

        • 1. Re: Can't see JNDI on remote server

          A NullPointerException does not give us much to
          work with.

          For 10,000 time post the full stack trace.

          Have you checked /etc/hosts or FAQ forum
          "Cannot connect to 127.0.0.1" or similar

          Regards,
          Adrian

          • 2. Re: Can't see JNDI on remote server
            vovan_onjava

            > A NullPointerException does not give us much to
            > work with.
            >
            > For 10,000 time post the full stack trace.
            >
            > Have you checked /etc/hosts or FAQ forum
            > "Cannot connect to 127.0.0.1" or similar
            >
            > Regards,
            > Adrian

            The strange thing is that I can execute the program correctly on my localhost, but when it goes to remote host: viktor.ld.ttu.ee, then the problem arise. The jboss installation on viktor.ld.ttu.ee is absolutely the same as on my localhost, and the port 1099 seems to be open (I tried telnet). I just wonder what could be wrong with it.

            The only exception I got is: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

            • 3. Re: Can't see JNDI on remote server
              jonlee

              Assuming you don't have any other network related errors, have you tried using the TimedSocketFactory to see if this has any impact? Add the following to your context properties before you do the lookup:
              jndiProps.setProperty("jnp.socketFactory", "org.jnp.interfaces.TimedSocketFactory");

              jndiProps.setProperty("jnp.timeout", "0");

              jndiProps.setProperty("jnp.sotimeout", "0");
              Context jndiContext = new InitialContext(jndiProps);
              etc.

              You can obviously add timeouts. I can't remember when we had this problem or what the exact conditions were but this did solve the issue for the particular environment.

              Hope it helps.