Question

If i'm creating the RMI registry from command line, the client has no problem in binding objects to the registry.

However, if i'm starting the RMI registry using ProcessBuilder, it's giving error.

This is my code for creating rmiregistry using ProcessBuilder

ProcessBuilder obj = new ProcessBuilder ("rmiregistry","2500");

Process obj_process = obj.start();

The error that i'm getting for using ProcessBuilder when I'm trying to bind to my own RMI registry

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
java.lang.ClassNotFoundException: node_func

node_func is an interface

Any ideas?

Was it helpful?

Solution

I don't see why you are starting a separate process when you could use LocateRegistry.createRegistry(). If you did that, this problem would disappear as well.

OTHER TIPS

The exception is occurring because the rmiregistry application doesn't know where to load classes from. When you attempt to bind an object in the RMI registry, the registry downloads the class definition for that object.

The correct way to handle the problem is to set the java.rmi.server.codebase property

(right click on your project->run as->run configuration->Arguments->VM arguments).

The property requires that a directory path be terminated with a forward slash, like so:

-Djava.rmi.server.codebase=file:${workspace_location}/folder/

You may also be having trouble if the ${workspace_location} variable is a relative path and the rmiregistry application was not started in the same directory so the relative path is not correct for it. If you either make the path absolute, or start the rmiregistry in the appropriate directory, the ClassNotFoundException should go away. See the tutorial on the java.rmi.server.codebase property for a little more detailed information.

Hope it helps.

Credits to this guy

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top