aspose file tools*
The moose likes Java in General and the fly likes Unreported Exeception Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Unreported Exeception Error" Watch "Unreported Exeception Error" New topic
Author

Unreported Exeception Error

Alan Blass
Ranch Hand

Joined: Mar 21, 2010
Posts: 119
Hi!

I am trying to read XML:



But on line 9, it says: unreported exception org.apache.commons.configuration.ConfigurationException; must be caught or declared to be thrown

But it is already inside a try catch. Please help. Thanks.
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Sorry but that can't be the whole story. I have just checked on org.apache.commons.configuration.ConfigurationException and it does extend Exception so it will be caught by your try/catch . Are you compiling the code you think you are?

P.S. Rather then return an empty string if you get an exception (it would seem to me to be fatal) should you not your self throw an exceptions that wraps the one you are catching?


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Alan Blass
Ranch Hand

Joined: Mar 21, 2010
Posts: 119
Errm...I can't compile it. See image:


James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Having downloaded 'Commons Configuration', when I try to compile your code under Netbeans I get

It seems that you are missing the class org.apache.commons.lang.exception.NestableException which presumably comes in a separate 'commons' package. Google is your friend.
Alan Blass
Ranch Hand

Joined: Mar 21, 2010
Posts: 119
Thanks. It works.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

It appears that because of the missing library (Apache Commons Lang judging from the package name), the compiler sees that a ConfigurationException is thrown but it cannot see that it is an indirect sub class of Exception.

In an analogy, you can't tell who my grandfather is if you don't know who my father is. You may know my father's name because I told you, but that still doesn't tell you who his father is. You'll have to ask my father himself.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: Unreported Exeception Error