File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is IllegalArgumentException an application exception

 
Chaminda Amarasinghe
Ranch Hand
Posts: 404
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Can you confirm that Is IllegalArgumentException an application exception?

thanks
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chaminda Amarasinghe
Ranch Hand
Posts: 404
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chaminda Amarasinghe
Ranch Hand
Posts: 404
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
since IllegalArgumentException is not an Checked Exception.

Doooh
 
Chaminda Amarasinghe
Ranch Hand
Posts: 404
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Christophe Verre:

Doooh


Hi bartender,

Do you think I am wrong?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic