• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

RMI blues

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spooky things happening....
I thought this was perfect... RemoteInterface lists the public Data methods,
The server implementation class:
public class ServerImpl extends UnicastRemoteObject implements RemoteInterface
In the FlightsTableModel class I have a class member:
RemoteInterface myDataObject
Dependant on the mode (local/network) I do:
if ( networkmode ) {
myDataObject =
(RemoteInterface) Naming.lookup("rmi://"+serverName+"/ServerImpl instance");
} else { // local mode
myDataObject = new ServerImpl("ServerImpl instance", dbname);
So, myDataObject can be used transparently in the client, without having to bother about the mode. The server process is running all the time.
... and it all works perfect, both in local and in network mode... except when I change mode. If I am in local mode, switch mode to network in the GUI (app terminates) and start the client again, it does not work (unless I stop and start the server process again).
There is no exception generated during the Naming.lookup(..) (although it takes some 10 seconds, probably timing out). However the program flow falls flat (ConnectException) on executing the first method on myDataObject. Why is this ? The local and remote databases are 2 separate files. I do not want to ask the examinator to stop and start the server !!
Who can help me ?? Thanks in advance.
- Arthur

[This message has been edited by Arthur Logtenberg (edited October 09, 2001).]
Arthur Logtenberg
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the solution myself. Had to read half the excellent book 'java.rmi, the remote method invocation guide', from Pitt/McNiff, before I got the clou (not from the book though): this method should NOT be executed in local mode:
Naming.rebind(name, this);
An extra mode (local/network) parameter to the constructor of ServerImpl enables me to avoid executing rebind(..) in local mode.
Now I think I have the perfect, most elegant solution, for using just 1 RMI-server class in both local and server mode.
Kind regards, Arthur

[This message has been edited by Arthur Logtenberg (edited October 12, 2001).]
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic