Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

RMI registry reset

843793Jan 14 2008 — edited Jan 20 2008
Hi there,
I'm writing a RMI application where I need to clean up the RMI registry as soon as the ip address of the server machine changes.
Let's say that I want to make an object (class Obj) accessible from a RMI client through the following code:
Obj obj = new Obj();
UnicastRemoteObject.exportObject(obj,RMIPort); //export the new object
registry = LocateRegistry.createRegistry(RMIPort); //Create a new registry
registry.rebind("myObject", obj); //Bind the object to the registry
Once I detect an ip change I need to clean up the register and I need to publish a new Obj object on it. The new object has to accessible from a RMI client instead of the previous. I tried something like:
UnicastRemoteObject.unexportObject(obj,RMIPort); //unexport the old object
Obj obj2 = new Obj(); //Create a new object
UnicastRemoteObject.exportObject(obj2,RMIPort); //export the new object
registry = LocateRegistry.getRegistry(RMI_PORT);
registry.rebind("myObject", obj2); //Bind the new object to the registry with the same name "myObject"
But when the last line of code is executed, an exception "java.rmi.UnmarshalException: Error Unmarshaling return header" is thrown.
Do you guys have any suggestions?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2008
Added on Jan 14 2008
4 comments
730 views