23

Decided to use Apache's Common Configuration package to parse an XML File.

I decided to do a:

XMLConfiguration xmlConfig = new XMLConfiguration(file);

To which Eclipse complained that I haven't caught an exception(Unhandled exception type ConfigurationException), so I hit the trusty surround with try/catch and it added the following code:

try 
    {
        XMLConfiguration xmlConfig = new XMLConfiguration(file);
    } 
    catch (ConfigurationException ex) 
    {
        ex.printStackTrace();
    }

However now it's complaining:

No exception of type ConfigurationException can be thrown; an exception type 
must be a subclass of Throwable

I don't understand why it's gave me that error when Eclipse is the one that suggested to add it.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Federer
  • 33,677
  • 39
  • 93
  • 121

3 Answers3

29

org.apache.commons.configuration.ConfigurationException extends org.apache.commons.lang.exception.NestableException.

Do you have Commons Lang on your path also? If not, Eclipse will fail to resolve the ConfigurationException class, and you'll get that error.

skaffman
  • 398,947
  • 96
  • 818
  • 769
  • 1
    Now I'm getting this error: `Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/Predicate`. Do you know why this is? So confused. I added it to my libraries in Eclipse! – Federer Mar 10 '10 at 13:14
  • 4
    @8EM: Looks like you need Commons Collections also. – skaffman Mar 10 '10 at 13:24
  • you may still get errors if you're not careful with the version dependencies on this.... check here for more info:http://stackoverflow.com/a/7651867/26510 – Brad Parks Mar 16 '12 at 13:52
  • For cases where more than one jar is needed for an import, how does one track down which jars are required? thanks for the tip on commons lang. – Mojave Storm Nov 22 '13 at 15:27
20

You need Apache Commons Lang 2.6

(Current release of Apache Common Configuration (1.8) wont works with version 3.1 of Apache Common Lang library, you might need to check Common configuration dependencies here )

Massimo Fazzolari
  • 5,185
  • 3
  • 27
  • 36
8

I also faced this problem. To fix this - Please download commons-lang-2.6.jar from http://commons.apache.org/proper/commons-lang/download_lang.cgi and add this commons-lang-2.6.jar to your project's build path. this should solve your problem.

Pankaj Kumar Katiyar
  • 1,474
  • 1
  • 20
  • 36