Search code examples
javarmiremote-serverremoteobject

How can i remove the remote object from the RMI runtime


When i shutdown the RMI server program by using, serverReg.unbind("LibraryServer"); it only remove the bound of remote object and it's key 'LibraryServer. If i start the server same time it give me an exception ObjID already in use. How can i entirety remove remote object from the registry ?. Binding statement of Remote object and it's key is,

serverReg.rebind("LibraryServer", new RemoteFactoryImpl());

Solution

  • When I shutdown the RMI server program by using, serverReg.unbind("LibraryServer"); it only remove the [binding] of remote object and it's key 'LibraryServer.

    Correct.

    If i start the server same time it give me an exception ObjID already in use.

    I'd like to see that exception and stack trace.

    How can I entirety remove remote object from the registry?

    You have already done so. You may be looking for a way to unexport the remote object, which is given by UnicastRemoteObject.unexportObject().

    However the ObjID already in use error can realistically only be coming from trying to export another Registry from a JVM in which you have already exported one. Which doesn't correspond with your description at all.