Search code examples
javarmijndinaming

Remote RMI Registry


I'm coding an application that requires remote binding, i.e., bind a remote object to a remote registry. By default, Java RMI Registry only binds locally, only remote objects that are binded in the same JVM/host.

I've seen some solutions that bypass this making a remote interface that will take a remote object and then bind locally (SO link of this disucssion). Isn't there a more elegant way to solve this? Maybe I should try to use JNDI with other provider??


Solution

  • I did some more research on this... First, if you have the same codebase on both servers, it should be as simple as this:

    ...
    Registry registry = LocateRegistry.getRegistry("192.168.1.1", 1100);
    registry.rebind("Hello, World!", myObj);
    

    But you can run into problems quickly if you need to load classes to the remote registry... you'll need a security manager: http://www.devx.com/getHelpOn/10MinuteSolution/20444

    I was still hoping you could post a code example or give us more information about your situation.