7 Replies Latest reply on Aug 8, 2006 1:34 PM by Tom Elrod

    rmi registry

    Lise E Newbie

      In the user docs for JBoss remoting, I find the sentence "registryPort - the port on which to create the RMI registry." Does this mean that there is a rmi registry somewhere that I can bind to? It says that default port is 3455, but doing

      LocateRegistry.getRegistry( 3455 );

      only gives me a

      java.net.ConnectException: Connection refused: connect

        • 1. Re: rmi registry
          Tom Elrod Master

          The RMIServerInvoker will call following upon being created:

          LocateRegistry.createRegistry(port)

          The port will be 3455 by default.

          Are you calling LocateRegistry.getRegistry( 3455 ) from a remote machine?

          • 2. Re: rmi registry
            Lise E Newbie

            I figured out my mistake, but I've run into another one. My code is the following:

            if (System.getSecurityManager() == null){
            System.setSecurityManager(new RMISecurityManager());
            }

            Properties env = new Properties();
            env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
            env.setProperty("java.naming.provider.url", "localhost:3455");
            env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");

            try {
            InitialContext context = new InitialContext(env);
            } catch (NamingException e) {
            e.printStackTrace();
            }

            try{
            InvokerLocator myLocator = new InvokerLocator("rmi://localhost:3455");
            RMIServerInvoker rmiserver = new RMIServerInvoker(myLocator);
            }catch(Exception e){
            e.printStackTrace();
            }


            No errors so far. But then I try to bind to the registry, with

            Naming.rebind( serverUrl, server );

            where serverUrl = rmi://localhost:3455/

            and server is a UnicastRemoteObject.

            This gives

            RemoteException occurred in server thread; nested exception is:
            java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
            java.lang.ClassNotFoundException: <server-class>_Stub

            I checked the class-folder, and the stub is there. If I create a local rmi-registry and bind to that (skipping all the above code expect the naming.rebind), everything works fine. But I would like the use the jboss rmi registry. What am I doing wrong?

            • 3. Re: rmi registry
              Lise E Newbie

              I foundt out that I actually do get an error before that. Calling
              RMIServerInvoker rmiserver = new RMIServerInvoker(myLocator);

              gives
              ERROR [org.jboss.remoting.transport.rmi.RMIServerInvoker - 246] Error unbinding RMIServerInvoker from RMI registry.
              java.rmi.NotBoundException: remoting/RMIServerInvoker/3455
              at sun.rmi.registry.RegistryImpl.unbind(RegistryImpl.java:140)
              at org.jboss.remoting.transport.rmi.RMIServerInvoker.destroy(RMIServerInvoker.java:242)
              at org.jboss.remoting.transport.rmi.RMIServerInvoker.finalize(RMIServerInvoker.java:260)
              at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
              at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
              at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
              at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)

              I have no idea why that is...

              • 4. Re: rmi registry
                falazar Novice

                How goes the RMI programming?

                I need to test a small RMI call for the jbpm myself.

                James

                • 5. Re: rmi registry
                  falazar Novice

                  Sorry, this appears to be the wrong forum.

                  (Unless anyone can send me the answer...)

                  James

                  • 6. Re: rmi registry
                    Lise E Newbie

                    I'm still facing the same errors. If someone has managed to use the rmi registry that RMIServerInvoker creates I would be very glad to hear how!

                    • 7. Re: rmi registry
                      Tom Elrod Master

                      Server code:

                      public class RMIRegistryTestServer
                      {
                       private Connector connector = null;
                       private String locatorUri = "rmi://localhost:4555";
                      
                       public void setUp() throws Exception
                       {
                       connector = new Connector(locatorUri);
                       connector.create();
                       connector.start();
                       }
                      
                       public void tearDown()
                       {
                       if(connector != null)
                       {
                       connector.stop();
                       connector.destroy();
                       }
                       }
                      
                       public static void main(String[] args)
                       {
                       RMIRegistryTestServer server = new RMIRegistryTestServer();
                       try
                       {
                       server.setUp();
                      
                       Thread.sleep(6000000);
                      
                       server.tearDown();
                       }
                       catch (Exception e)
                       {
                       e.printStackTrace();
                       }
                       }
                      
                      }
                      


                      Client code:

                      public class RMIRegistryTestClient
                      {
                       public void testRegistry() throws Exception
                       {
                       Registry registry = LocateRegistry.getRegistry("localhost", 3455);
                       if (registry != null)
                       {
                       String[] entries = registry.list();
                       if (entries != null)
                       {
                       for (int x = 0; x < entries.length; x++)
                       {
                       System.out.println("entry " + x + ": " + entries[x]);
                       }
                       }
                       else
                       {
                       System.out.println("Failed to get entries.");
                       }
                       }
                       else
                       {
                       System.out.println("Failed to get regsitry.");
                       }
                      
                       String[] listing = Naming.list("//localhost:3455");
                       if(listing != null)
                       {
                       for(int x = 0; x < listing.length; x++)
                       {
                       System.out.println("listing " + x + ": " + listing[x]);
                       }
                       }
                       else
                       {
                       System.out.println("Failed to get listing.");
                       }
                       }
                      
                       public static void main(String[] args)
                       {
                       RMIRegistryTestClient client = new RMIRegistryTestClient();
                       try
                       {
                       client.testRegistry();
                       }
                       catch (Exception e)
                       {
                       e.printStackTrace();
                       }
                       }
                      }