0 Replies Latest reply on Aug 10, 2007 8:24 AM by Ana Lorite

    Cannot connect to a RMI server (RMI) from JBoss (JNDI)

    Ana Lorite Newbie

      Hi everyone. I hope I am in the right forum.

      I have problems to access to a remote RMI server from JBoss. I mean JBoss is the client.

      My application run under Unix. My JBoss version is 4.0.2.

      Following i describe my scenario:

      - The Server: a pure java RMI server:

      step 1) i start the RMI Registry:
      agilent:/> rmiregistry -J-Djava.class.path=. &

      step 2) i run the java rmi server.
      agilent:/> java HelloServer
      Hello Server is going to be already....
      Hello Server already!

      My server code is the following:
      HelloImpl obj = new HelloImpl();
      System.setProperty("java.security.policy", "java.policy");
      System.setSecurityManager(new RMISecurityManager());
      System.out.println("Hello Server is going to be already....");
      Naming.rebind("HelloServer", obj);
      System.out.println("Hello Server already!");

      - The Client: A class within JBoss. My client code is the following:

      String server = "rmi://";

      try {
      if (System.getSecurityManager()== null){
      log.debug("GestorColeta::executeRemote ==> Crear RMISecurityManager");
      System.setSecurityManager(new RMISecurityManager());
      }else log.debug("GestorColeta::executeRemote ==> Ya existe RMISecurityManager");

      Registry registry = LocateRegistry.getRegistry("");

      if (registry != null){
      String[] entries = registry.list();

      if (entries != null){
      for (int x = 0; x < entries.length; x++){
      log.debug("GestorColeta::executeRemote ==> Vinculos disponibles[" + x + "]:" + entries[x] );
      }else log.debug("GestorColeta::executeRemote ==> Fallo al obtener vínculos disponibles");
      } else log.debug("GestorColeta::executeRemote ==> Fallo al obtener el registro");

      /*Properties prop = new Properties();

      Context c = new InitialContext(prop);*/

      log.debug("GestorColeta::executeRemote ==> Naming lookup...");
      //Hello gestor = (Hello) c.lookup("HelloServer");
      Hello gestor = (Hello) registry.lookup(server);
      log.debug("GestorColeta::executeRemote ==> Naming lookup... OK!!");

      And i obtain the next:

      12:52:42,472 DEBUG [uploadmanager] GestorColeta::executeRemote ==> Ya existe RMISecurityManager
      12:52:42,488 DEBUG [uploadmanager] GestorColeta::executeRemote ==> Vinculos disponibles[0]:HelloServer
      12:52:42,488 DEBUG [uploadmanager] GestorColeta::executeRemote ==> Naming lookup...
      12:52:42,511 ERROR [uploadmanager] GestorColeta::GestorColeta: ==> rmi://
      12:52:42,511 ERROR [uploadmanager] GestorColeta::GestorColeta: ==> java.rmi.NotBoundException

      As you can see, i get the entries list from the registry... but i cannot lookup the HelloServer service. :-(

      I tried to run the commented code: Hello gestor = (Hello) c.lookup("HelloServer"); but i had no good news:

      13:56:16,949 DEBUG [uploadmanager] GestorColeta::executeRemote ==> Ya existe RMISecurityManager
      13:56:16,967 DEBUG [uploadmanager] GestorColeta::executeRemote ==> Vinculos disponibles[0]:HelloServer
      13:56:16,968 DEBUG [uploadmanager] GestorColeta::executeRemote ==> Naming lookup...
      13:56:21,983 ERROR [uploadmanager] GestorColeta::GestorColeta: ==> Receive timed out
      13:56:21,984 ERROR [uploadmanager] GestorColeta::GestorColeta: ==> javax.naming.CommunicationException
      13:56:21,985 ERROR [uploadmanager] GestorColeta::GestorColeta: ==> java.net.SocketTimeoutException: Receive timed out

      I changed the rmi.codebase.server in my JBoss run.sh: -Drmi.codebase.server.... (by default is ) but if i change this property all my EJBeans and Servlets fail

      Reading the forums i could obtain the list of the rmi services on the server... And i knew that JBoss use JNDI instead RMI so I tried jnp:// instead of rmi://. Nothing.

      This topic is very interesting http://www.jboss.org/index.html?module=bb&op=viewtopic&t=56265

      Oh, your using the rmi registry Naming.list, not the jndi Context.list as I thought. JBoss does not implement an rmi registry. Use jndi.

      so: how can I use JNDI to connect to a RMI server?

      I am literally desesperated. Can anyone give me a ray of light? It will be really appreciated. :)

      Thanks in advance.