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 IllegalArgumentException an application exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 9317
    
109

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: 9317
    
109

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is IllegalArgumentException an application exception
 
Similar Threads
Why does this compile and not throw an exception until run-time?
Checking method parameters for validity
Identifying Exception types
Exception Doubt
double.parseDouble() - Exception