2 Replies Latest reply on Dec 10, 2002 10:12 AM by pazu

    Unable to lookup EJB's in remote client

    pazu

      Hello folks,

      I'm unable to lookup a EJB in a remote (swing) client. It seems that the NamingContext insists in using the local address (127.0.0.1) for lookups, despite the value of the java.naming.provider.url property. Here's what I'm doing:
      [pre]Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      props.put(Context.PROVIDER_URL, "jnp://10.72.2.32:1099");
      context = new InitialContext(props);

      // name and clazz are defined elsewhere
      return PortableRemoteObject.narrow(context.lookup(name), clazz);[/pre]
      However, this code fails with the following exception:
      [pre]javax.naming.CommunicationException.
      Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1;
      nested exception is:

      java.net.ConnectException: Connection refused: connect
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
      at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
      at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:469)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:448)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at com.telebahiacelular.movistore.client.RemoteUtils.lookup(RemoteUtils.java:32)
      ...[/pre]
      What could be wrong? Why it's using 127.0.0.1 even when I've set the provider URL to a different address? By the way, this used to work fine when I run JBoss on the same machine. Now that I (finally) moved JBoss out of my development machine, I can't connect anymore.

        • 1. Re: Unable to lookup EJB's in remote client
          mikefinn

          What version of JBoss are you using? We are doing this w/ 3.0.x and it works. (though we aren't setting URL_PKG_PREFIXES, but I don't think that matters).

          mike

          • 2. Re: Unable to lookup EJB's in remote client
            pazu

            That's JBoss 3.2.0beta2.

            However, I've already found the problem. The machine where JBoss was running had it's hostname incorrectly setted up. It's server name (singapura.teleleste.int) was listed in /etc/hosts with an IP of 127.0.0.1. When I changed /etc/hosts so the hostname is associated with the correct IP, everything went fine.