11 Replies Latest reply: Sep 18, 2010 5:12 AM by EJP RSS

    Connection Refused


      I have compiled my RMI code on JDK 1.6.0_20 and the code was working fine. I moved my code to a linux environment with jdk1.6.0_02 and also worked well. However I moved my .class files to an another linux environment with JRE 1.5.0_16-b02 it gave me the following error

      Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

      AND I downloaded JRE 1.6.0_21 and when I ran I gave the {FILE PATH}/java ..... COMMAND then it gave me an error saying

      Server registration failed_ Error: java.rmi.ConnectException: Connection refused to host:; nested exception is:
      java.net.ConnectException: Connection refused
        • 1. Re: Connection Refused
          See item [A.1 in the RMI FAQ|http://download.oracle.com/javase/6/docs/technotes/guides/rmi/faq.html#domain].
          • 2. Re: Connection Refused

            The A.1 in the RMI FAQ. talk about when I am trying to look up an exported object in a different host. But the issue that I have is when I am trying to export the object.
            • 3. Re: Connection Refused
              It's impossible to tell without the entire strack trace, but it looks to me more like it happened when you were trying to bind* the object into the Registry. In which case the explanation is simply that the Registry isn't running.
              • 4. Re: Connection Refused

                Most of the things I manged to sort out. However, Now that I have up my registry and and server program (exports only one Object) on and then I tried to start the Client which exports 10 Objects I started them on and I am getting the following error.

                +[globus@node182 ART]$ java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:+
                java.rmi.AccessException: Registry.Registry.rebind disallowed; origin / is non-local host

                MY CODE IS LIKE BELOW:
                *try {*+
                Client_Interface stub = (Client_Interface) UnicastRemoteObject.exportObject(oClient, 0);+
                Registry registry = LocateRegistry.getRegistry(oClient.registryHost);+
                registry.rebind(o_Host+"Client_Obj" + oClient.i_ClientID, stub);+
                System.out.println("Client instance " + iID + " Created");+

                +*} catch (Exception e) {*+

                oClient.registryHost =
                • 5. Re: Connection Refused
                  An RMI Registry can only accept bindings from processes running in the same host.

                  Why do your clients need to bind in the Registry at all? Normally they just supply their remote objects to the server when registering callbacks, via a remote method call.
                  • 6. Re: Connection Refused

                    So you mean if I only export the Client Object to the Registry that is on 10.0.0183 i do not need to bind it? and Can the server or any local program look up for the Clients exported object on

                    A note on my architecture...

                    SERVER > HAS 10 CLIENTS REPORTING

                    IF SO?
                    try {
                    Client_Interface stub = (Client_Interface) UnicastRemoteObject.exportObject(oClient, 0);
                    System.out.println("Client instance " iID " Created");

                    } catch (Exception e) {
                    • 7. Re: Connection Refused
                      Your terminology is incorrect and this is adding to the confusion.

                      1. Constructing a class that extends UnicastRemoteObject constitutes exporting it. If it doesn't extend UnicastRemoteObject, calling UnicastRemoteObject.exportObject() constitutes exporting it. This has nothing to do with the Registry.

                      2. Putting an object into the Registry is called +'binding'.+ You only need to do this for remote objects that can't be accessed any other way. Specifically, the first* one that is used by a client. After that, the remote object can accept other remote objects as parameters or return them as results, and so on recursively forever.

                      3. Clients that export remote objects are usually providing callbacks, and they can be registered with the server as parameters of a remote method call to the server:
                      // The client's remote object implements something like this ...
                      public interface Callback extends Remote
                        void callMeBack(...) throws RemoteException;
                      // The server implements something like this ...
                      public interface RegisterCallback extends Remote
                        void registerCallback(Callback callback) throws RemoteException;
                      // the client get the server object out of the Registry, creates its callback, and registers it with the server:
                      If on the other hand this isn't your architecture, your clients aren't really clients at all, they are more servers, and if they need to be looked up in a Registry you will need to run an RMI Registry on each such client host. This is very unusual.

                      Not knowing what a 'slave' means in your context I can't comment further.
                      • 8. Re: Connection Refused
                        So in short, I cannot export an object and bind to same to a registry that is running in another machine?
                        • 9. Re: Connection Refused
                          So in short, I cannot export an object and bind to same to a registry that is running in another machine?
                          You cannot bind to a registry that is running in another machine.
                          • 10. Re: Connection Refused
                            what if I use the CodeBase property and keep all the .class in the same machine as the registry is running?
                            • 11. Re: Connection Refused
                              You cannot bind to a Registry that is running in another machine.

                              Exporting has nothing to do with it.

                              The codebase feature has nothing to do with it either.