Using Exceptions with EJBs

The J2EE architecture provides for the detection and handling of exceptions. There are two kinds of exceptions: system exceptions and application exceptions. Application exceptions indicate recoverable-type problems (for example, bad user input or a requested purchase item being unavailable). The EJB container propagates application exceptions to the remote client, who presumably will have a catch handler in place to correct the problem (if possible) or take evasive action. The NoTrackListException shown in Listing 4.3 on page 95 is an example of an application exception. Application exceptions should be subclasses of Exception.

System exceptions indicate nonrecoverable errors, such as a lost database connection or ...

Get Enterprise JavaBeans™ Component Architecture: Designing and Coding Enterprise Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.