Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checked application exception

 
Alexandre Fradin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Application exceptions that are checked exceptions
may be defined as such by being listed in the throws clauses of the methods of the bean�s business
interface.

Does it mean that an Exception may be a Application exception for a business method and a system exception for an other one, for example :




Is my example true?

Thanks for help.

[ August 11, 2008: Message edited by: Alexandre Fradin ]
[ August 11, 2008: Message edited by: Alexandre Fradin ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

// here an application exception
// there a system exception

Your example is not that great, as you're throwing the same exception System exceptions are not application exceptions. There are three patterns :
  • Application exceptions that are checked exceptions may be defined as such by being listed in the throws clauses of the methods.
  • An application exception that is an unchecked exception is defined as an application exception by annotating it with the ApplicationException metadata annotation, or denoting it in the deployment descriptor with the application-exception element.
  • 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.


  • Your example uses a checked exception (extending Exception), so it has to be defined in the throws clause of the method. Here is another example, with two application exceptions, one checked and one unchecked :

     
    Alexandre Fradin
    Greenhorn
    Posts: 11
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ok thank you Christophe.

    I missed the third point... So in my example, MyException is an application exception for both m1() and m2().
     
    Christophe Verré
    Sheriff
    Posts: 14691
    16
    Eclipse IDE Ubuntu VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes, a checked application exception.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic