So I was using LocateRegistry.createRegistry()
, but this has a problem: namely, it runs within the process that calls it, so if I am using more than one JVM, then a crash to the JVM that started the registry will take down the registry for all the JVMs.
So it looks like I need to use rmiregistry (or something?) to isolate the process that does RMI lookup/binding from the server JVMs.
I tried to do this, and now I get this error when I try to do Registry.rebind()
:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: {my remote interface name}
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
What am I doing wrong? I googled this exception & it has something to do with the RMI codebase, but I'm really lost here. If the problem is in the rmiregistry
command, what are the command-line options to tell it what to do? If the problem is in my server JVM, what do I need to do?
What crash? I haven't seen a JVM crash for years. Unless you have JNI the JVM containing your RMI servers is no more likely to crash than the standalone JVM started by the rmiregistry command. And using LocateRegistry.createRegistry() solves your class path problems forever.