File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes JVM copies an object when it is exported to RMI registry? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "JVM copies an object when it is exported to RMI registry?" Watch "JVM copies an object when it is exported to RMI registry?" New topic
Author

JVM copies an object when it is exported to RMI registry?

Rafael Z. Frantz
Greenhorn

Joined: Mar 09, 2010
Posts: 20
Hi guys,

I've noticed that when an object is exported to the RMI registry the JVM makes a copy of it. Is it true?

Is there any way to export an object without making this copy?

Thanks,

Rafael.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

http://java.sun.com/developer/technicalArticles/Programming/serialization/


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rafael Z. Frantz
Greenhorn

Joined: Mar 09, 2010
Posts: 20
Hi Maneesh,

Thanks for your message, but I am afraid the problem is different. Let me explain it better with this code:






1) The monitor is exported to the RMI registry
2) Proxy is an object created at AnotherClass and when AnotherClass invokes wait() the proxy holds the lock.
3) Proxy is not exported to the RMI registry
4) When Monitor constructor is executed the output is:

PROXY 1 tdg.guarana.toolkit.port.communicator.adapter.jbi.responder.Proxy@1862525
PROXY 2 tdg.guarana.toolkit.port.communicator.adapter.jbi.responder.Proxy@1862525

PROXY 3 tdg.guarana.toolkit.port.communicator.adapter.jbi.responder.Proxy@8720392 <<<<<<<<<<<<<<<< The problem!

As you can see latter when update() is called the object seems to be another one. I am wondering this is due to the object proxy was copied to the RMI registry.

What's your opinion about it?

Regards,

Rafael.

Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Your code does not compile and i don't think you have given us the entire code. I don't see anyone calling the update() method.
Are these two classes executed in different JVMs?


apigee, a better way to API!
Rafael Z. Frantz
Greenhorn

Joined: Mar 09, 2010
Posts: 20
Hi,

These 3 classes are running in a JVM1 and the update() method is invoked by another object that runs in a JVM2. All them in both JVMs are exported to RMI registry, one registry in JVM1 and another at JVM2. The code is not complete since it is long and complex. I´ve tried to put something that focus on the problem.

In JVM1 then proxy calls wait() and own the lock, the problem is that at the time it is exported to the registry at JVM1 the stub at the registry that receives the notification from JVM2 that invokes update(). In this case, the update at the stub cannot call NotifyAll() since it does not own the lock. So no effect in the code...

Regards,

Rafael.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JVM copies an object when it is exported to RMI registry?
 
Similar Threads
Not implementing the RemoteException
RMI Question: Is server a thread?
RMI Reaper Thread
wait() in web services
Need to extend UnicastRemoteObject class