1 Reply Latest reply on Feb 20, 2003 8:12 AM by Adrian Brock

    RMI Doesn't work remotely

    Jeremy Newbie

      I've got a simple entity EJB deployed to JBoss called "User". I have written a simple client to communicate with that EJB over RMI.
      The setup works fine when the client and JBoss are running on the same system. However when I try to get the client to talk to JBoss on a different system (with the same deployed EJB), it fails. Here's the relevant code snippets :

      System.setProperty("java.naming.factory.initial",
      "org.jnp.interfaces.NamingContextFactory");
      System.setProperty("java.naming.factory.url.pkgs",
      "org.jboss.naming:org.jnp.interfaces");
      System.setProperty("java.naming.provider.url", "127.0.0.1:1099");

      InitialContext jndiContext = new InitialContext();
      Object ref = jndiContext.lookup("UserRemote"); //returns UserRemote
      reference

      This works fine (JBoss running local), I get a reference to the
      UserRemote interface and can proceed from there.
      However, when I point the client at a JBoss server on a different
      host, the return value of jndiContext.lookup("UserRemote") is null,
      and I don't get an exception thrown :
      System.setProperty("java.naming.provider.url", "10.0.1.13:1099");

      InitialContext jndiContext = new InitialContext();
      Object ref = jndiContext.lookup("UserRemote"); // returns null
      This is not a network issue. Port 1099 is open on 10.0.1.13. I have
      watched with a packet sniffer and see bidirectional TCP communication
      between client and JBoss server on port 1099.
      In playing around with this, I tried the following :
      Enumeration enum = jndiContext.list(nameString);
      where nameString was any of "", "10.0.1.13:1099", "10.0.1.13", etc.

      This always resulted in the following exception :
      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)
      This strikes me as odd, as I am connecting to 10.0.1.13, not 127.0.0.1
      (loopback).
      Perhaps someone can help with my questions :
      1) Are there any other environment variables I need to set to tell the
      client where to connect to? As you can see I have set
      "java.naming.provider.url" to "10.0.1.13:1099", which is correct.
      2) Am I setting the provider URL correctly? I have seen other
      postings with URL's preceded by rmi://IP:port, iiop://IP:port, etc.
      3) Are there security/access controls in JBoss that would prohibit
      connections from other than localhost (127.0.0.1)? I am working with
      a default install, no configuration changes.
      4) If none of the above, what am I doing wrong?
      Thanks in advance,
      Jeremy