wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI and it's unknown ways 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 and it Watch "RMI and it New topic
Author

RMI and it's unknown ways

Adrian Muscalu
Ranch Hand

Joined: May 08, 2000
Posts: 73
Hi everyone,

I was testing my application and I've discovered that after calling <b>unbind</b> and checking with <b>list</b> that the RMI registry doesn't contain the entry for my remote object, the clients can still invoke methods on the remote object at their leisure. No exceptions are thrown!!!

However, new clients get an exception (which is the right behaviour) upon trying to get a remote object.
Moreover, if I close the Server application completely than I do get the expected behaviour, the clients (new or old) will get an exception.

Now, I could close the server all the time without fancying around with <b>unbind</b> but I am afraid that I am only hiding a bigger problem; maybe my RMI approach is not the right one.

My remote object has an instance variable which is the Data class. All clients are expected to get stubs that point to the same instance of the remote object.

I am thinking that the Data class was passed somehow by copy and not by reference to the client.

Testing is done in the same JVM, on the same machine.

Any ideas on why this might happen?

Thank you all in advance,
Adrian


SCJP2, SCWCD
rinke hoekstra
Ranch Hand

Joined: Apr 06, 2007
Posts: 152
the clients can still invoke methods on the remote object at their leisure. No exceptions are thrown!!!


Don't know, still have to start with the RMI part and dive in to it. Are you sure that your classpath is not simply pointing to the remote object so that it just has access to it bypassing RMI?


_ _ ________________________ _ _ <br /> <br />Just SCJP (but 93%)
Adrian Muscalu
Ranch Hand

Joined: May 08, 2000
Posts: 73
yes, I am sure.
Thanks for replying.
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Originally posted by Adrian Muscalu:
Hi everyone,

I was testing my application and I've discovered that after calling <b>unbind</b> and checking with <b>list</b> that the RMI registry doesn't contain the entry for my remote object, the clients can still invoke methods on the remote object at their leisure. No exceptions are thrown!!!

However, new clients get an exception (which is the right behaviour) upon trying to get a remote object.
Moreover, if I close the Server application completely than I do get the expected behaviour, the clients (new or old) will get an exception.

Now, I could close the server all the time without fancying around with <b>unbind</b> but I am afraid that I am only hiding a bigger problem; maybe my RMI approach is not the right one.

My remote object has an instance variable which is the Data class. All clients are expected to get stubs that point to the same instance of the remote object.

I am thinking that the Data class was passed somehow by copy and not by reference to the client.

Testing is done in the same JVM, on the same machine.

Any ideas on why this might happen?

Thank you all in advance,
Adrian


This is the correct behavior for RMI to the best of my knowledge.

When you unbind the remote object it means that new clients cannot obtain a reference to that remote object using the RMI registry. However unbind does not destroy the object it just means that prospective new clients can no longer use the RMI registry to access it.

As the existing client already have a obtained a reference to the remote object they can continue to use it as normal. While all these existing remote client references remain the remote object will continue to exist.

Mark
[ July 11, 2007: Message edited by: Mark Smyth ]

SCJP<br />SCJD
Adrian Muscalu
Ranch Hand

Joined: May 08, 2000
Posts: 73
Hi Mark,

Thanks for taking the time to answer.
It is a relief to know that I haven't misused RMI and the program behaves as expected.

Cheers,
Adrian
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: RMI and it's unknown ways