Handling Exceptions
Handling Exceptions
The output from the timer is sent to the server.log file located in the
domain-dir/server/logs/ directory.
View the output in the Admin Console:
1. Open the Admin Console by opening the following URL in a web browser:
http://localhost:4848/
2. Enter the admin username and password to log in to the Admin Console.
3. Click Application Server in the navigation pane.
4. Click View Log Files.
5. At the top of the page, you'll see this line in the Message column:
Timeout occurred
Alternatively, you can look at the log file directly. After about 30 seconds, open server.log in a
text editor and you will see the following lines:
TimerSessionBean: Timeout occurred
Handling Exceptions
The exceptions thrown by enterprise beans fall into two categories: system and application.
A system exception indicates a problem with the services that support an application. Examples
of these problems include the following: a connection to an external resource cannot be
obtained or an injected resource cannot be found. If your enterprise bean encounters a
system-level problem, it should throw a javax.ejb.EJBException. Because the EJBException
is a subclass of the RuntimeException, you do not have to specify it in the throws clause of the
method declaration. If a system exception is thrown, the EJB container might destroy the bean
instance. Therefore, a system exception cannot be handled by the bean's client program; it
requires intervention by a system administrator.
An application exception signals an error in the business logic of an enterprise bean. Application
exceptions are typically exceptions that you've coded yourself, such as the BookException
thrown by the business methods of the CartBean example. When an enterprise bean throws an
application exception, the container does not wrap it in another exception. The client should be
able to handle any application exception it receives.
If a system exception occurs within a transaction, the EJB container rolls back the transaction.
However, if an application exception is thrown within a transaction, the container does not roll
back the transaction.
Handling Exceptions
The Java EE 5 Tutorial · September 2007
674