File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes java.rmi.ConnectException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "java.rmi.ConnectException" Watch "java.rmi.ConnectException" New topic


K. Tsang

Joined: Sep 13, 2007
Posts: 3059

Hi all, java.rmi.ConnectException is subclass of java.rmi.RemoteException. I encounter this situation:

1. start RMI server
2. run network client
3. do something eg search/book etc
4. stop server
5. do something -> got ConnectException and NOT EXIT APP
6. start server again
7. do something -> still get ConnectException

Why is this? I use a service layer in between client and server. When I start my client, I have a getService method to get the server/database instance. Then I pass this parm to my other objects.

K. Tsang JavaRanch SCJP5 SCJD OCPJP7 OCPWCD5 OCPBCD5 OCPWSD5 OCMJEA5 part 1 part 2/3
Kevin Florish
Ranch Hand

Joined: Jan 06, 2009
Posts: 179
As far as I am aware this is correct behaviour.

Stopping the server severs the link you had when you started your client (proxy/stub relationship). So restarting the server won't reconnect this
link and so after stopping and restarting the server you still need to restart the client to reconnect the link. At least this is my understanding and
is also the way my code works.

Java5 Tutorials | Java6 Tutorials | HTML/CSS Tutorials | JavaScript and jQuery Tutorials
K. Tsang

Joined: Sep 13, 2007
Posts: 3059

Thanks Kevin, then my app is behaving correctly.
Alain Dickson
Ranch Hand

Joined: Dec 08, 2008
Posts: 53
My RMI connection behaves like this: have a look at the link
I agree. Here's the link:
subject: java.rmi.ConnectException
It's not a secret anymore!