In the Enterprise JavaBeans 3.0, Final Release specifications page 356 it says
“An application exception may be a subclass (direct or indirect) of java.lang.Exception (i.e., a “checked exception”), or an application exception class may be defined as a subclass of the java.lang.RuntimeException (an “unchecked exception”).”
And in page 357 it says
“A system exception is an exception that is a java.rmi.RemoteException (or one of its subclasses) or a RuntimeException that is not an application exception.”
I can’t understand what will happen to the transaction if we throw RuntimeException in a bean method. Is that transaction get rollback or ?
As far as I understand it, a RuntimeException is a system exception and will therefore cause a transaction to be rolled back UNLESS it is annotated with @ApplicationException, you can also cause the application exception to rollback the transaction if you add @ApplicationException(rollback=true), the default is rollback=false.