Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is that RuntimeException subclasses are system Exceptions or application exception.

 
Udara Amarasinghe
Ranch Hand
Posts: 109
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Pie
Posts: 2337
87
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, all the RuntimeExceptions not annotated as an ApplicationException will cause a Rollback

Regards,
Frits
 
Will Myers
Ranch Hand
Posts: 381
Java jQuery Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah friends thank you very much
that's correct I found it on the specification too ..
 
Udara Amarasinghe
Ranch Hand
Posts: 109
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 381
Java jQuery Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you can...not sure why you would want to either
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic