File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Using Sockets to pass an RMI Reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Using Sockets to pass an RMI Reference" Watch "Using Sockets to pass an RMI Reference" New topic

Using Sockets to pass an RMI Reference

P Reen

Joined: Jun 17, 2005
Posts: 2

I have 2 processes A and B.
Both already communicate via Sockets.

I need B to use a callback on an object in A.
This is an RMI Object.

When I pass the Reference to the RMI object in a serialized Object to B, B involkes the callback method.

However The callback is executed on B.
i.e. It looks like the Remote RMI Object is serialized accross to B and B then involkes the method on the newly created RMI object living in its process.

I have tried passing Interface refs, Object Refs and RemoteRefs but to no avail.

I can't see the issue as I thought java will not serialize any object which extends remote.

Any ideas

John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
Can you post some code so that we know what we are talking about?
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
You cannot send a remote object reference over the wire and call it. That's not how it works. There is a Remote interface. Your remote interface extends that. Your remote class impelements the interface. You must then deploy your remote interface to an RMI server to indicate where the actual remote object lives. The client (e.g., socket B) does a lookup in the registry and gets an instance of the remote proxy that implements the remote interface. The proxy calls are marshalled over the wire to the actual object on the remote server.
I agree. Here's the link:
subject: Using Sockets to pass an RMI Reference
It's not a secret anymore!