1 2 Previous Next 16 Replies Latest reply: Aug 16, 2010 11:51 PM by 843793 RSS

    RMI application deployment issues

    843793
      All,

      I have developed an application using RMI and am in need of help for the deployment of sed program as I have tried numerous different ways to release.

      Along those lines, I also am not too clear on the codebase and how to release to a http://+hostname+:+port+/+program_name+.

      Here are the facts:
      ~The application makes use of 2 container work servers to mitigate logs on the server, I will name the interfaces worker1.java, worker2.java (with worker1Impl.java and worker2Impl.java).
      ~The application contains the client, secondary phase client2, and the server with named interfaces client.java, client2.java and server.java (clientImpl.java, client2Impl.java and serverImpl.java).
      ~The worker servers have their own containers, worker1Cont.java and worker2Cont.java. There is an all-purpose mainCont.java acting a message container.
      ~The codebase already contains protocol like rmi://host:port/application.
      ~The stubs are already in place and I am using Genady's RMI Eclipse plugin to do so (might need to be redone using cmd and rmic).
      ~Windows user (switching soon I promise :)).

      With all of that eyeful displayed, what I need is simple when I deploy, the application will be used for cross network distribution so remote access is a must, which is why none of the stubs are loading. It all works locally (server and client on same machine).

      Here is the directory structure for reference (server, client, and common are in same project):

      Root Directory
      -----
      ->src
      | |->mult
      | | |->client/clientImpl
      | | |->client2/client2Impl
      | | |-worker1
      | | | |->worker1/worker1Impl
      | | |->worker2
      | | | |->worker2/worker2Impl
      | |->containers
      | | |->worker1Cont
      | | |->worker2Cont
      | | |->mainCont
      |->server
      | |->server/serverImpl
      -----

      Thanks for your help in advance,

      cbarton.a
        • 1. Re: RMI application deployment issues
          EJP
          Along those lines, I also am not too clear on the codebase and how to release to a http://+hostname+:+port+/+program_name+.
          You don't. You install the JAR files on a Web server, anywhere you like, and set the codebase at the RMI server JVMs to the URL of those JARs. However if you're not using stubs you really don't need the codebase feature at all unless you are using serializable interfaces as remote method return values and don't want to distribute the implementation classes. Again I will assume this is not the case and that you therefore don't need the codebase feature at all.
          ~The application makes use of 2 container work servers to mitigate logs on the server,
          'Mitigate logs'?

          I don't understand any of your terminology about containers and so forth, but you need to build 3 JAR files:

          1. The remote stubs if any, remote interfaces, and any application classes they depend on, recursively until closure.
          2. The server implementation objects.
          3. The client code.

          Both 2 and 3 should name (1) in the Class-Path of their manifest files.

          Deploy (1) and (2) to servers, (1) and (3) to clients.

          That's it.
          ~The codebase already contains protocol like rmi://host:port/application.
          No it doesn't. That's not a codebase protocol, it is an RMI lookup protocol. Nothing to do with the codebase.
          ~The stubs are already in place
          Why? Don't use them. If your remote objects extend UnicastRemoteObject and call super(0) or super(port) in their constructors, or alternatively call UnicastRemoteObject.exportObject(remote, port, ...), you haven't needed them since 1.5 came out about six years ago. Your life will be considerably simpler without them.
          • 2. Re: RMI application deployment issues
            843793
            Thank you for the reply,

            I am now running into this problem:
            java.security.AccessControlException: access denied (java.net.SocketPermission cbarton.mine.nu resolve)
            ...
            after compiling all of the files and so on... I have read everything about it and cannot seem to get the issue under control.

            Here is what I have set up:
            security.policy (for both client and server):
            grant {
                 permission java.security.AllPermission;
                 permission java.net.SocketPermission "cbarton.mine.nu:8888", "accept, connect, listen, resolve";
            }
            run configurations:
            On both the client and the server. I have tried every which way with these two combinations.
            -Djava.security.policy=security.policy
            -Djava.rmi.server.codebase=http://cbarton.mine.nu:8888/Server

            In the code:
            Server:
            on the cbarton.mine.nu
            System.setSecurityManager(new RMISecurityManager());
            Registry reg = LocateRegistry.createRegistry(8888);
            reg.rebind("/Server", wm);
            //UnicastRemoteObject.exportObject(this); 
            I have tried doing an export object on the server and not but makes no difference.

            Client:
            on another machine with line of sight to cbarton.mine.nu
            if ( System.getSecurityManager() == null )
                 System.setSecurityManager(new RMISecurityManager());
            Server server = (Server)Naming.lookup("//cbarton.mine.nu:8888/Server");
            UnicastRemoteObject.exportObject(this);
            The error is coming from the Naming.lookup.

            Thanks for the help,

            cbarton.a
            • 3. Re: RMI application deployment issues
              EJP
              1. Run it with -Djava.security.debug=access,failure to see whether your security policy is in effect. Probably your security.policy file isn't being found, but there are other possibilities.
              2. Setting the codebase at the client does nothing unless the client exports remote objects.
              3. Exporting remote objects at the client isn't done unless you want the server to callback the client.
              4. You don't need a security manager at the client unless the server has set a codebase and you are expecting to download client classes from it.
              5. You don't need a security manager at the server unless the client has set a codebase and you are expecting to upload client classes from it.
              • 4. Re: RMI application deployment issues
                843793
                Taking out all of the security, I am getting a
                java.rmi.NotBoundException: WordMoleServer
                     at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:106)
                     at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
                        ...
                However on the server, it is clearly bounded and the client has visibility to the server.

                I have packaged all of the classes in one jar in order to do a deploy on the application.

                If there is any more knowledge you need to know please let me know.

                Just in case you were wondering, the program in question is at [http://wordmole.sourceforge.net/] and you can open up the svn from there. the most recent commit is what I am running off of.

                The server should be up as well ping cbarton.mine.nu

                cbarton.a

                Edited by: cbarton.a on Aug 12, 2010 1:15 AM
                • 5. Re: RMI application deployment issues
                  EJP
                  Registry reg = LocateRegistry.createRegistry(8888);
                  'reg' needs to be static.
                  reg.rebind("/Server", wm);
                  Reg.rebind("Server", wm);
                  • 6. Re: RMI application deployment issues
                    843793
                    Ejp,

                    I have done that and now I am getting a connection refusal on the client side.

                    I am thinking of two options for this project,

                    1) Redesign the project to use the simple 3 jar system and hope it works (might be coming back to the forums if it does not because of your expertise)
                    2) Go with JNLP and WebStart.

                    A question if you know on option 2:

                    What advantages over RMI does WebStart have? Is it the same nit picky type deployment one experiences with RMI or is it cleaner and easier to attain a higher level of scalability in the application?

                    Is it WebStart more clean to release over say a webserver background that I am running.

                    Thank you so much for all your help,

                    If you prefer another form of communication, let me know.

                    cbarton.a
                    • 7. Re: RMI application deployment issues
                      EJP
                      (a) Is the connection refusal to the correct host? the same port as the Registry? If the host is wrong see java.rmi.server.hostname and item A.1 in the RMI FAQ.

                      (b) Redesigning the JAR layout is a good idea but it won't solve (a).

                      (c) My only recent experience with JNLP is via applets.
                      • 8. Re: RMI application deployment issues
                        843793
                        The java.rmi.server.hostname trick worked.

                        Now I am getting a
                        java.security.AccessControlException: access denied (java.net.SocketPermission cbarton.mine.nu resolve)
                             at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
                             at java.security.AccessController.checkPermission(AccessController.java:546)
                        I have put back the SecurityManager because it could not download the stub without it:
                        java.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
                             java.lang.ClassNotFoundException: server.WordMoleServerImpl_Stub (no security manager: RMI class loader disabled)
                             at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
                             at java.rmi.Naming.lookup(Naming.java:84)
                        Here is the security.policy on both client and server (I have tried cbarton.mine.nu:8888 and just cbarton.mine.nu in the socket permission):
                        grant {
                             permission java.security.AllPermission;
                             permission java.net.SocketPermission "cbarton.mine.nu", "accept, connect, listen, resolve";
                        };
                        EDIT:

                        I just found my server was erroring out ( the port on the ip varies and increases in each error in the 50000 range)
                        java.security.AccessControlException: access denied (java.net.SocketPermission 169.254.192.34:50325 resolve)
                             at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
                             at java.security.AccessController.checkPermission(AccessController.java:546)
                        My local ip is not that; it was an ip for another connection but i terminated that connection yet it's still erroring.

                        Edited by: cbarton.a on Aug 12, 2010 8:23 PM
                        • 9. Re: RMI application deployment issues
                          EJP
                          See [reply 3|http://forums.sun.com/thread.jspa?messageID=11034138#11034138] item 1.
                          • 10. Re: RMI application deployment issues
                            843793
                            Nothing comes up with that debugger (-Djava.security.debug=access,failure)

                            Only error is
                            Exception in thread "RMI TCP Connection(idle)" java.security.AccessControlException: access denied (java.net.SocketPermission 169.254.192.34:53315 accept, resolve
                            ...
                            • 11. Re: RMI application deployment issues
                              EJP
                              That's not possible. It prints out yards of stuff. Did you set it on the JVM that got that exception? Did you specify it where system property settings are supposed to be set in the java command line?
                              • 12. Re: RMI application deployment issues
                                843793
                                I have split up the project into two jar files, a common including the client and the server (this is all that made sense since there are too many dependencies for the client in the common to break them up. All of the interfaces reside in this jar).

                                On the client side, I am still getting that
                                java.security.AccessControlException: access denied (java.net.SocketPermission cbarton.mine.nu resolve)
                                . Running the debugger:
                                access: domain that failed ProtectionDomain  (file:/C:/Users/Chris/workspace/WordMole/bin/ <no signer certificates>)
                                 sun.misc.Launcher$AppClassLoader@27a8c4e7
                                 <no principals>
                                 java.security.Permissions@6639c8c1 (
                                 (java.net.SocketPermission localhost:1024- listen,resolve)
                                access: access denied (java.awt.AWTPermission accessEventQueue)
                                java.lang.Exception: Stack trace
                                On the server side, sorry last time I misspelled one of params thats why it did not load, but,
                                it does load with no errors. and when I debug, the only failures I receive are: a file permission to a temp directory and the protectiondomain as above to WordMoleServer/bin.

                                cbarton.a
                                • 13. Re: RMI application deployment issues
                                  EJP
                                  The protection domain permissions printed in the debug output don't agree with the .policy file you posted. That suggests your .policy file isn't being found.

                                  Also your .policy file's SocketPermission doesn't specify a port range.
                                  • 14. Re: RMI application deployment issues
                                    843793
                                    Ok here is where I am at now.

                                    I have 2 jar files as that makes the most sense for my program... a client.jar containing all of the client and base class files including all of the interfaces. There is the server.jar including all of the implementations and stubs for the server and its components.

                                    I have released the server on address [http://cbarton.mine.nu/WordMoleServer.jar] and updated its codebase when I run it as
                                    java -jar -Djava.security.policy=security.policy -Djava.rmi.server.codebase=http://cbarton.mine.nu/WordMoleServer.jar WordMoleServer.jar
                                    for the server.
                                    java -jar -Djava.security.policy=security.policy WordMoleClient.jar
                                    for the client.

                                    The security.policy is in direct los of the home dir, so the policies should be found, yet I receive that same debugging error...

                                    The security.policy files have been modified to allow a
                                    permission java.net.socketPermission "localhost:8888", "accept, listen, connect"
                                    and all of the ports have been specified for the other one.

                                    Is this going in the right direction? I am still receiving that failure to resolve on the client as well as the other errors in the past.

                                    cbarton.a
                                    1 2 Previous Next