File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Is that RuntimeException subclasses are system Exceptions or application exception. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Is that RuntimeException subclasses are system Exceptions or application exception." Watch "Is that RuntimeException subclasses are system Exceptions or application exception." New topic
Author

Is that RuntimeException subclasses are system Exceptions or application exception.

Udara Amarasinghe
Ranch Hand

Joined: Aug 17, 2009
Posts: 109

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 ?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1675
    
  25

Yes, all the RuntimeExceptions not annotated as an ApplicationException will cause a Rollback

Regards,
Frits
Will Myers
Ranch Hand

Joined: Aug 05, 2009
Posts: 326

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.
Udara Amarasinghe
Ranch Hand

Joined: Aug 17, 2009
Posts: 109

yeah friends thank you very much
that's correct I found it on the specification too ..
Udara Amarasinghe
Ranch Hand

Joined: Aug 17, 2009
Posts: 109

Is that we can declare to throw subclasses of java.rmi.RemoteException directly from business interface method throws clause without wrap it with EJBException.
Will Myers
Ranch Hand

Joined: Aug 05, 2009
Posts: 326

I don't think you can...not sure why you would want to either
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is that RuntimeException subclasses are system Exceptions or application exception.