Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Arthur Logtenberg

+ Follow
since Oct 11, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Arthur Logtenberg

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).]
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).]