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


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Unreported Exeception Error" Watch "Unreported Exeception Error" New topic
Author

Unreported Exeception Error

Alan Blass
Ranch Hand

Joined: Mar 21, 2010
Posts: 106
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: 106
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: 106
Thanks. It works.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

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
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Unreported Exeception Error
 
Similar Threads
Need an understanding why I am getting "incompatiable types"
New to JDBC - problems
how to throw exception from class level static block?
Commons ConfigurationException
reading from a file