Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4090972

rmi Connections fail to a Win95-computer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.1.4
    • core-libs
    • x86
    • windows_nt



      Name: rm29839 Date: 11/05/97


      We try to do rmi between different computers.
      The App works in the following configs:
         - local in a WinNT(Client, Server)
         - local in a Win95(Client, Server)
         - remote WinNT(Client) WinNT(Server)
      The App fails
         - remote WinNT (Client) Win95(Server) (seems not to receive a connection)
         - remote Win95(Client) WinNT(Server) (establishes connection and fails for callback to client object)
         - remote Win95(Client) Win95(Server) (not establishing connection)

      The App is derived from the docs/rmi/examples/hello-Example
      and does a callback to the client.

      Code is here:
      File Hello.java -------------------------------------------------------------
      package examples.hello;

      public interface Hello extends java.rmi.Remote {
          String sayHello(Holle obj) throws java.rmi.RemoteException;
          String sayHello(Testobject t) throws java.rmi.RemoteException;
          String sayHello( ) throws java.rmi.RemoteException;
      }


      File Holle.java -------------------------------------------------------------
      // The callback-interface

      package examples.hello;

      public interface Holle extends java.rmi.Remote {
          String sayHolle() throws java.rmi.RemoteException;
      }

      File HelloImpl.java ----------------------------------------------------------
      package examples.hello;


      import java.rmi.*;
      import java.rmi.server.*;
      import java.rmi.server.UnicastRemoteObject;
      import java.rmi.registry.LocateRegistry;

      public class HelloImpl extends UnicastRemoteObject implements Hello
      {
          private String name;

          private String getClient()
          {
             String s = "<unbekannt>";
             try
             {
                s = getClientHost();
             }
             catch ( ServerNotActiveException e )
             {
                System.out.println("Server: " + e);
             }
             return s;
          }

          public HelloImpl(String s) throws java.rmi.RemoteException
          {
            super();
            name = s;
          }

          static int cnt = 0;
          public String sayHello(Testobject t) throws RemoteException
          {
            System.out.println( "Server: " + "Anfrage erhalten von " + getClient() + " (mit Testobject)");
            System.out.println( "Server: Testobject " + t.incName());
            cnt ++;
            return "Server says: Hello World-" + cnt + ":" + t.incName();
          }
          public String sayHello(Holle obj) throws RemoteException
          {
            System.out.println( "Server: " + "Anfrage erhalten von " + getClient() + " (mit obj)");
            System.out.println( "Server: " + obj );
            System.out.println( "Server: " + obj.sayHolle());
            cnt ++;
            return "Server says: Hello World (" + cnt + ", mit obj)";
          }
          public String sayHello() throws RemoteException
          {
            System.out.println( "Server: " + "Anfrage erhalten von " + getClient() + " (ohne Parameter)");
            cnt ++;
            return "Server says: Hello World (" + cnt + ", ohne Parameter)";
          }

          public static void main(String args[])
          {
            System.out.println("Server: create and install the security manager");
            System.setSecurityManager(new RMISecurityManager());

            try
            {
               System.out.println("Server: creating registry");
               LocateRegistry.createRegistry(2112);
               String my_name = "//:2112/HelloServer";
               System.out.println("Server: creating new Server '" + my_name + "'" );
               HelloImpl obj = new HelloImpl(my_name);
               Naming.rebind( my_name, obj );
               System.out.println( "Server created and bound in the registry to the name '" + my_name + "'");
               System.out.println( "Server: " + obj );
            }
            catch (Exception e)
            {
               System.out.println( "Server: " + "HelloImpl.main.exception:");
               e.printStackTrace();
            }
         }
      }
      File HelloClient.java --------------------------------------------------------------------------
      package examples.hello;

      import java.io.*;
      import java.rmi.*;
      import java.rmi.server.*;
      import java.rmi.server.UnicastRemoteObject;
      import java.net.InetAddress;

      public class HelloClient extends UnicastRemoteObject implements Holle, Serializable
      {
         private String addr, name;

         public HelloClient(String s, String a) throws java.rmi.RemoteException
         {
            super();
            name = s;

            addr = ("//" + a + ":2112/HelloServer");
      // System.setSecurityManager(new RMISecurityManager());

            try
            {
               System.out.println("Local Host: "+ InetAddress.getLocalHost());
               Hello obj = (Hello) Naming.lookup( addr );

               System.out.println("Client: Server Objekt erzeugt (" + addr + "): " + obj);

               message = obj.sayHello( ); System.out.println("message="+message+" (ohne Parameter)");
               message = obj.sayHello( new Testobject("eins") ); System.out.println("message="+message+" (mit obj)");
               message = obj.sayHello( (Holle)this ); System.out.println("message="+message+" (mit obj)");

               Testobject t = new Testobject("zwei");
               for (int i = 0; i < 3; i ++ )
                  System.out.println(i+". message="+obj.sayHello( t ));
            }
            catch (Exception e)
            {
               System.out.println("HelloClient.exception:");
               e.printStackTrace();
            }
         }

         String message = "";

         static public void main ( String argv[] )
         {
            String addr = "hepp-nt";

            if (argv.length > 0) addr = argv[ 0 ];

            System.out .println("Client: Adresse " + addr );

            try
            {
               HelloClient x = new HelloClient ("HelloClient", addr );

               System.out.println( "Client: " + x );
            }
            catch (Exception e)
            {
               System.out.println( "Client: " + "HelloClient.main.exception:");
               e.printStackTrace();
            }
            System.exit ( 0 );
         }

         static int cnt = 0;
         public String sayHolle() throws RemoteException
         {
            System.out.println( "Client: " + "Anfrage von Server erhalten");
            cnt ++;
            return "Antwort von Client: " +cnt;
         }
      }

      File Testobject.java ------------------------------------------------------

      package examples.hello;

      import java.io.*;

      public class Testobject implements Serializable
      {
         String name;
         static int cnt;
         public Testobject( String n )
         {
            name = n;
            cnt = 0;
         }
         public String incName()
         {
            return name + "_" + (cnt++);
         }
         public String toString()
         {
            return "Testobject[name=" + name + ",cnt="+ cnt + "]";
         }
      }

      Files end here ------------------------------------------------


      Error message from WinNT(Client) to Win95(Server)

      L:\RMI\EXAMPLES\HELLO>java examples.hello.HelloClient 138.200.187.62
      Client: Adresse 138.200.187.62
      Local Host: hepp-nt/138.200.187.79
      Client: Server Objekt erzeugt (//138.200.187.62:2112/HelloServer): examples.hello.HelloImpl_Stub[RemoteStub [ref: [endpoint:[
      ALG.aat-f.aeg-f.de:1173](remote),objID:[1cc776:cc27eef464:-8000, 0]]]]
      HelloClient.exception:
      java.rmi.UnknownHostException: Unknown host: [ALG.aat-f.aeg-f.de:1173]; nested exception is:
              java.net.UnknownHostException: ALG.aat-f.aeg-f.de
              at sun.rmi.transport.tcp.TCPChannel.openSocket(TCPChannel.java:238)
              at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:125)
              at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:73)
              at examples.hello.HelloImpl_Stub.sayHello(HelloImpl_Stub.java:31)
              at examples.hello.HelloClient.<init>(HelloClient.java:56)
              at examples.hello.HelloClient.main(HelloClient.java:83)
      Client: examples.hello.HelloClient[RemoteStub [ref: [endpoint:[hepp-nt:1597](local),objID:[0]]]]


      Error message from Win95(Client) to WinNT(Server)

      C:\TMP\rmi\examples\hello>java -Djava.rmi.server.hostname=ALG.aat-f.aeg-f.de examples.hello.HelloClient
      Client: Adresse hepp-nt
      Local Host: ALG.aat-f.aeg-f.de/138.200.187.62
      Client: Server Objekt erzeugt (//hepp-nt:2112/HelloServer): examples.hello.HelloImpl_Stub[RemoteStub [ref: [endpoint:[hepp-nt:1577](remote),objID:[1ea785:cc27a7b7ee:-8000, 0]]]]
      message=Server says: Hello World (1, ohne Parameter) (ohne Parameter)
      message=Server says: Hello World-2:eins_1 (mit obj)
      HelloClient.exception:
      java.rmi.ServerException: Server RemoteException; nested exception is:
              java.rmi.UnknownHostException: Unknown host: [ALG.aat-f.aeg-f.de:1112];
      nested exception is:
              java.net.UnknownHostException: ALG.aat-f.aeg-f.de
      Client: examples.hello.HelloClient[RemoteStub [ref: [endpoint:[ALG.aat-f.aeg-f.de:1112](local),objID:[0]]]]
      (Review ID: 18737)
      ======================================================================

            ldorninsunw Laird Dornin (Inactive)
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: