This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Is IllegalArgumentException an application exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Is IllegalArgumentException an application exception" Watch "Is IllegalArgumentException an application exception" New topic
Author

Is IllegalArgumentException an application exception

Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Hi all

Can you confirm that Is IllegalArgumentException an application exception?

thanks
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9956
    
163

As per the definition of an application exception:

The Bean Provider defines application exceptions. 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, home interface, component interface, and web service endpoint. 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.


So you will have to declare IllegalArgumentException in throws clause of the method or defined it as an application exception through the annotation or deployment descriptor.


[My Blog] [JavaRanch Journal]
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Hi Jaikiran,

Thanks for the reply,

I dont think that specifying unchecked IllegalArgumentException in throws clause, IllegalArgumentException becomes an Application Exception.

Since its is already compiled we cant use annotations also, My next question is can we use deployment descriptor,

And isnt there any Application Exceptions defined in JDK?

Thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I dont think that specifying unchecked IllegalArgumentException in throws clause, IllegalArgumentException becomes an Application Exception.

You'll have to believe Jaikiran Any checked exception defined in the throws clause of a method is an application exception.


[My Blog]
All roads lead to JavaRanch
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Originally posted by Christophe Verre:

You'll have to believe Jaikiran Any checked exception defined in the throws clause of a method is an application exception.


Christophe, I cant belive Jaikiran since IllegalArgumentException is not an Checked Exception.

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9956
    
163

Originally posted by Chaminda Amarasinghe:
Christophe, I cant belive Jaikiran since IllegalArgumentException is not an Checked Exception.



Good point I was under the impression that any exception in the throws clause of the bean interface will be considered as ApplicationException. Looks like i am wrong

I even decided to read the "System Exceptions" section in the spec to see what it contains. And the statement in this section now confuses me:

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.


The latter part of the statement confuses me. So we can have a RuntimeException (which is termed as "unchecked") as an application exception? If this is possible, then i think declaring this IllegalArgumentException (which is an RuntimeException) in the throws clause should have behaved as an application exception.

I am a bit confused right now, but let me do more reading to see what's expected
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

since IllegalArgumentException is not an Checked Exception.

Doooh
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Originally posted by Christophe Verre:

Doooh


Hi bartender,

Do you think I am wrong?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Is IllegalArgumentException an application exception
 
Similar Threads
Identifying Exception types
Checking method parameters for validity
Why does this compile and not throw an exception until run-time?
Exception Doubt
double.parseDouble() - Exception