Hi All, I am seeing a mock test question that asks if to throw a EJBException from a CMT bean will roll back the current transaction if any. I searched in EJB specs, all I found that is to throw a Application exception will not doom the transaction. I don't see it mentions anywhere if to throw an EJBException will doom the Tx. So I am at a loss, can somebody share some insight on this? -David
posted 16 years ago
Oops, I found out the answer. The EJB specs does say to throw an EJBException will doom the Tx. In section "18.2.2 System Exceptions", it says: The Bean Provider can rely on the container to perform the following tasks when catching a non-application exception: � The transaction in which the bean method participated will be rolled back. � No other method will be invoked on an instance that threw a non-application exception. -David
An EJBException indicates a problem within the container itself (e.g. you are trying to access an object that no longer exists), rather than an application (business logic) issue. If an EJBException is thrown it indicates a bug in your code or the configuration of the container. The transaction will not be committed.