• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Sockets to pass an RMI Reference

 
P Reen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Thanks
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post some code so that we know what we are talking about?
 
Rick O'Shay
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic