I've found the answer to my own question. This may or not be the solution to your problem. ConnectException may occur owing to various reasons; this is just one of them.
Well, my problem was due to the fact that I was prematurely
terminating my RMI server process, because of a misconception I had about the way the whole RMI mechanism works. As a result, there was no server to connect to, because I had killed it unintentionally.
Here is what I thought originally:
"The main
thread of my RMI server JVM will be the only non-daemon
thread of that JVM. As soon as it terminates, the JVM will terminate also. My remote requests will be serviced by the RMI registry directly (!). Why not put some System.exit() statements in my server's main() method so that I return an RC to the OS?"
Well, there were two errors in my thoughts above:
1) There is another non-daemon thread in my RMI server JVM, namely RMI Reaper. It is one of a bunch of threads created by the RMI runtime. This thread will prevent the JVM from dying...
2) ... so that it services my remote requests. RMI service no requests itself! It is nothing more than a name server. That's all it's in it.
Actually, this is even a known RMI "non-bug" ; see the Bug Parade,
http://developer.java.sun.com/developer/bugParade/bugs/4384670.html Panagiotis.
[This message has been edited by Panagiotis Varlagas (edited October 29, 2001).]