This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes how to unbind a remote object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "how to unbind a remote object?" Watch "how to unbind a remote object?" New topic
Author

how to unbind a remote object?

Ramses Tutoli
Greenhorn

Joined: Sep 05, 2003
Posts: 26
Can someone tell me what's wrong with the following code? It doesn't work, but no exception is caught either.

the remote object was previously registered with a call to Naming.rebind("contractor", remoteObject);
Tony Collins
Ranch Hand

Joined: Jul 03, 2003
Posts: 435
You may have unbind'ed the connection factory but the remote objects it creates may still be on the server.
Tony
[ September 24, 2003: Message edited by: Tony Collins ]
Vlad Rabkin
Ranch Hand

Joined: Jul 07, 2003
Posts: 555
Hi Ramses,
It doesn't work, but no exception is caught either.


What do you mean by saying that it doesn't work?
Best,
Vlad
Ramses Tutoli
Greenhorn

Joined: Sep 05, 2003
Posts: 26
I don't have a ConnectionFactory. my remote object is my remote implementation of Data.
"It doesn't work" means that it doesn't seem to unbind the remote object. A subsequent call to rebind() gives me the following error:
java.rmi.server.ExportException: internal error: ObjID already in use
Failed To Register object with the RMI registry
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Try getting some more info about the state of the system before and after the unbind():

This may offer more clues, or not. And make sure you see before and after messages. If there's no after, it may mean theres an Error (or other Throwable) being thrown and caught somewhere else (since the code shown only catches Exception, which is normally what you want, but if you've got code somewhere else that manages to hide the error message of an Error...


"I'm not back." - Bill Harding, Twister
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11437
    
  85

Hi Ramses,
You could also try turning RMI debugging on (see the Useful java.rmi and sun.rmi Properties on the Sun RMI Home page). Then see if the registry gives any information about why it is not unbinding the instance.
Ahhh, the light dawns. This is not a problem with your unbind. For a start, calling rebind() will not warn you about an existing object being bound - it just overwrites it. If you use bind, and the object already exists, then you get a totally different exception: java.rmi.AlreadyBoundException.
The exception you are getting is the one you get when you try to start the registry a second time. If you do that, then you get an stack trace similar to:

See that second last line? The one that has the "LocateRegistry.createRegistry" in it? Do you get that? If not, please post your entire stack trace.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Ramses Tutoli
Greenhorn

Joined: Sep 05, 2003
Posts: 26
Andrew, you are right. It was the call the createRegistry() that caused the problem. There doesn't seem to be a way to "uncreate" the registry in Java (other than closing the app), since unbind() just removes the remote object.
I worked my way around this by calling createRegistry() when the server window is opened, and just adding buttons that either bind or unbind the remote object.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1372
I worked my way around this by calling createRegistry() when the server window is opened, and just adding buttons that either bind or unbind the remote object.


How should we check server window is opened ?
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

kri shan wrote:How should we check server window is opened ?


Howdy, Kri.

Champ, did you see how old this thread is? Instead of waking up zombie threads, please start new ones next time. Also, when you do so, please be more precise in your question (the one you made is too vague).


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to unbind a remote object?