• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 22783
131
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.
reply
    Bookmark Topic Watch Topic
  • New Topic