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

Remote obj may be unreachable if ref doesnt use ip or fully qualified domainName

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      x86, sparc
    • OS:
      solaris_2.5.1, solaris_2.6, windows_nt

      Backports

        Description

        I have a server running on rudra.eng.sun.com, as well as a registry at port
        10099. When I try to invoke a method on a Remote reference obtained via a
        registry lookup from ohio.central.sun.com, I get an unknown host exception for
        the server host. Somehow RMI loses the domainname when making the newServer
        remote call.

        - jre1.1.5/bin/jre -cp .:jma.zip xDomain rudra.eng.sun.com
        local host is ohio
        looking up rmi://rudra.eng.sun.com:10099/managedObjFactory/JmaDispatch
        looked up com.sun.em.server.jma.JmaDispatcherImpl_Stub[RemoteStub [ref: [endpoint:[rudra:33193](remote),objID:[1dce0818:cedfa0c057:-8000, 0]]]]
        creating new server rudra.eng.sun.com
        java.rmi.UnknownHostException: Unknown host: [rudra:33193]; nested exception is:
                java.net.UnknownHostException: rudra
                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 com.sun.em.server.jma.JmaDispatcherImpl_Stub.newServer(JmaDispatcherImpl_Stub.java:29)
                at xDomain.connectTo(xDomain.java:51)
                at xDomain.main(xDomain.java:31)

        test case follows. to duplicate, one will have to replace JmaDispatcherRmi...

        import java.rmi.*;
        import java.net.*;

        import com.sun.em.server.jma.JmaDispatcherRmi;

        public class xDomain extends java.applet.Applet {

            public void init() {
            }

            public void start() {
                String hostname = getCodeBase().getHost();
                connectTo(hostname);
            }

            public static void main(String[] args) {
                if (args.length < 1) {
                    System.err.println("Missing argument: hostname");
                    return;
                }
                try {
                    String localhost =
                        java.net.InetAddress.getLocalHost().getHostName();
                    System.out.println("local host is "+localhost);
                }
                catch (java.net.UnknownHostException e) {
                    e.printStackTrace();
                }
                
                String hostname = args[0];
                connectTo(hostname);
            }

            static void connectTo(String hostname) {
                String serverName = "rmi://" + hostname + ":" +
                    Integer.toString(10099) +
                    "/managedObjFactory/JmaDispatch";
                System.out.println("looking up "+serverName);
                try {
                    JmaDispatcherRmi remoteObj =
                        (JmaDispatcherRmi) Naming.lookup(serverName);
                    System.out.println("looked up "+remoteObj);

                    System.out.println("creating new server "+hostname);
                    String newSrvrName = remoteObj.newServer(hostname); <<-- fails
                    System.out.println("created server "+newSrvrName);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                ldorninsunw Laird Dornin (Inactive)
                Reporter:
                akhil Akhil Arora (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: