1

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?

Jason S
  • 184,598
  • 164
  • 608
  • 970

1 Answers1

1

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.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • My JVMs crash all the time because they use RxTx which has plenty of native code problems. So I need to isolate them in a separate process. – Jason S Apr 16 '11 at 15:05
  • Anyway, that's not my question. "using LocateRegistry.createRegistry() solves your class path problems forever." -- could you elaborate? – Jason S Apr 16 '11 at 15:06
  • 1
    @Jason S: You have a ClassNotFoundException, because the Registry couldn't find the class named, because it wasn't on its classpath, but if the Registry is in the same JVM it is on the classpath, same as it is for the remote object, and everything else in the JVM, so you don't get that error, as you already discovered. – user207421 Apr 18 '11 at 05:31