Application Exception and EJB Transaction. If I throw a custom ApplicationException from a business method in Entity bean which is participating in a transaction, would the transaction be rolled back by container? Does container rolls back transaction only in case of SystemExceptions?

Alessandro A. Garbagnati

The short answers are: No and Yes.

A SystemException is a subtype of java.lang.RuntimeException, while an ApplicationException is any Exception that does not extends neither java.lang.RuntimeException nor java.rmi.RemoteException.

Said so, we have to add that an EJB Transaction is automatically rolled back only when a SystemException (or a subtype of it) is thrown.