0

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());
user207421
  • 305,947
  • 44
  • 307
  • 483
ccc
  • 370
  • 5
  • 19
  • Can you please explain little more.. Your code seems good. What is you expectation. – Siva Kumar Sep 15 '15 at 05:11
  • Simply, i need start my server after shutdown it many times. For the first time i started server and shutted down it works fine. After shuted down the server and try to start it again with same port and same remote object and same key `LibraryServer` it gave me that exception. – ccc Sep 15 '15 at 05:21

2 Answers2

3

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.

user207421
  • 305,947
  • 44
  • 307
  • 483
-1

Ok, i found an answer for that, unbined method only removes connection between remote object and its key. So cannot restart the rmi server with same remote object because first remote object still in the registry. By using unexportObject method of UnicastRemoteObject class can be entirely remove remote object from registry. I found it from a post of this.

UnicastRemoteObject.unexportObject(serverReg, false);
ccc
  • 370
  • 5
  • 19
  • You've misunderstood. `unbind()` removes the object from the Registry. `unexportObject()` unexports the object. They aren't the same thing. – user207421 Oct 16 '15 at 08:56