Rebind error and java.rmi.server.codebase
843793Oct 17 2007 — edited Oct 18 2007My RMI server application creates the RMI registry and binds some remote objects to this registry, programatically.
There is no problem with the following code:
Registry registry = LocateRegistry.createRegistry(1099);
registry.rebind("XXX", remoteObject);
but if I don't want to use this "registry" reference provided by the createRegistry.
I have two possible alternatives:
Registry registry = LocateRegistry.getRegistry("XXX.XXX.XXX.XXX", 1099);
registry.rebind("XXX", remoteObject);
or
Naming.rebind("//XXX.XXX.XXX.XXX:1099/XXX", remoteObject);
Both alternatives raise the following exception:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: XXXXXXXXXXXXXX_Stub
What's the difference?. Because the stub classes (generated by rmic) are in the classpath of the application.
This problem is solved if I include the system property java.rmi.server.codebase pointing to the stub classpath. But this approach is rather ugly.
Can I use the Naming.rebind or the LocateRegistry.getRegistry without the java.rmi.server.codebase property?
Thanks in advance,
Jaime