Error handling in CORBA Java components

Handle errors occurring during component execution gracefully, as follows:

  1. Write detailed descriptions of the error to the log. This will help you debug the problem later. You can call any of the System.out.print methods to write to the log (the output is redirected).

  2. If the error prevents the current transaction from completing, roll it back; for details, see “Set transactional state” in Chapter 11, “Creating CORBA Java Components” of the EAServer Programmer’s Guide.

  3. Throw an exception with a brief, descriptive message appropriate for display to an end user of the client application.

Java components can record errors or status messages to the server’s log file. Writing to the log creates a permanent record of the error, and log messages can be automatically stamped with the date and time that the message was written. Call any of the System.out.print methods to write to the log.

You can also throw an uncaught exception. Ideally, any exception thrown by your component should be a standard CORBA IDL exception or a user-defined IDL exception; the latter must be listed in the raises clause of the IDL method definition and the throws clause of the equivalent Java method declaration. All exceptions are forwarded to the client, but only exceptions defined in IDL can be rethrown by the client stub as a duplicate of the server-side exception.

CORBA ORB and EAServer EJB clients receive forwarded exceptions differently: