Two Laptop Bag
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI Question another one ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI Question another one ?" Watch "RMI Question another one ?" New topic

RMI Question another one ?

Tony Collins
Ranch Hand

Joined: Jul 03, 2003
Posts: 435
I'm trying to unbind my connection factory, so I can stop client accessing the Server while I re-cache the Database. Though I'm having problems, I receive the ExportError Exception: ObjID Already in use when I try to create the registry for the second time.
My code is as Follows

So is there anyway of un-creating the registry once it's created, without quiting the application ? Or have people just quit the application if they want rid of the RMI connection, which to me seems a bit rubbish.
Any help would be appreciated ?
Tony Collins
Ranch Hand

Joined: Jul 03, 2003
Posts: 435
Looking through the Sun developers forum the only way to stop the RMI registry is to exit the main thread. Why I don't know ?
So restarting the Server progrmatically seems to be a little difficult and I would think not worth the hassle.
I wonder if all entrys in the registry are deleted when it is stoped via exit.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

Hi Tony,
In your case, I think all you need to do is unbind() your remote object from the registry. You can leave the registry running while you re-cache the database. Any client that then tries to get a reference to your remote object will fail. This should meet your requirements.
Alternatively: don't try to code for this at all . After all, there is no requirement to re-cache the database.
It has also been mentioned quite a few times in this forum that it does not appear to be programattically possible to shut down the registry.
I would guess that this is because of complexity / security reasons. You would presumably need the registry to listen on some other "administration" port for commands such as shutting down the registry. You would probably want to password protect it (so it cannot be shut down by a malicious user). You would probably want some command to just disable new registrations first, before removing existing registrations. You would probably want to have some way of notifying existing clients that their registrations is being removed. And so on.
I think the only thing you can do is just exit() your main application which will shut down the registry.
If you wanted to be nice you could check if anyone else has registered with your registry first, and display a warning message if that does happen. (But since most people don't set up the security necessary for other applications to register with their registry, I guess this can't happen anyway, so you might also wan't to skip it).
Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
I agree. Here's the link:
subject: RMI Question another one ?
It's not a secret anymore!