File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:exceptions while the registering and binding -process Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:exceptions while the registering and binding -process" Watch "NX:exceptions while the registering and binding -process" New topic
Author

NX:exceptions while the registering and binding -process

Ulrich Heeger
Ranch Hand

Joined: Jun 06, 2003
Posts: 266
Hi everyone,
I'm reffering to this thread, where one question remained open:
1. Concerning the handling of the MagicCookieException and IOException which may occur while accessing the db-file and reading the header-informations (while calling the getMetaData()-method):
Within my Server GUI, I have decided to create for the RoomServer Class a new exception, called StartServerException.Within the startServer-method I have following exception handling:

My Server GUI will catch the StartServerException and will display the message to the user and alert him that the server will shut down:

Andrew wrote in another thread:

You cannot stop the Sun RMI Registry programattically.
You can stop (or unbind) your server process from the registry, and then bind a new server process to the registry

That's why I decided to shut down my server if an excpetion occured during the registering and binding-process, otherwise it could be quite complicate to recovery from this exception.
What do you think about that? How have you handled this or a similar problem?
Thanks in advance
Ulrich
Terry Martinson
Ranch Hand

Joined: Oct 18, 2003
Posts: 293
Ulrich -
In the case of an IllegalFileFormat, I force shut down of the server with appropriate alert box to user and corresponding console log message. It seemed to get complex if I attempted to try again after that error occurred (i.e. even if I let them change the file name in the server GUI, I think I still had problems).
However, in the case of invalid port or port already in use, it worked fine if I just allowed the server GUI user to change the port number and try again.
TJ


SCJP, SCJD, SCWCD, SCBCD
Ulrich Heeger
Ranch Hand

Joined: Jun 06, 2003
Posts: 266
Hi Terry,
Thanks for your reply

In the case of an IllegalFileFormat, I force shut down of the server with appropriate alert box to user and corresponding console log message. It seemed to get complex if I attempted to try again after that error occurred (i.e. even if I let them change the file name in the server GUI, I think I still had problems).
However, in the case of invalid port or port already in use, it worked fine if I just allowed the server GUI user to change the port number and try again.

Before the registering- and binding process I make a validation of the portnumber, checking if the portnumber is a digit between 1024 and 65535.
If not, an IllegalArgumentException is thrown which won't be wrapped in a StartServerException. Thus, the Server GUI handles this exception differently and doesn't exit.
But I have omitted my messages within the StartServerException, I mean I will only throw new StartServerException(remoteEx). Thus, the association between exception and invalid portnumber isn't obviously anymore.
My handling at the caller's side now looks like:

Regards,
Ulrich
[ January 20, 2004: Message edited by: Ulrich Heeger ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX:exceptions while the registering and binding -process