Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Unreported Exeception Error

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Alan Blass
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Errm...I can't compile it. See image:


 
James Sabre
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. It works.
 
Sheriff
Posts: 22563
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic