#java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester

sharath Yogananda picture sharath Yogananda · Feb 16, 2015 · Viewed 33.7k times · Source

I am getting java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester error and I am stuck with this error for more than a month. I have tried all Digester versions available and I also checked for duplicate JARs in classpath.

I have designed the report through iReport-5.6.0 and I used the JARs from the iReport-5.6.0\ireport\modules\ext and other required JARs.

Error-Log:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:108)
    at net.sf.dynamicreports.examples.JasperMongoDBConnection.main(JasperMongoDBConnection.java:30)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.digester.Digester
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at sun.misc.Launcher$ExtClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 2 more

Answer

exoddus picture exoddus · Feb 16, 2015

If NoClassDefFoundError is thrown you should check that needed jars are properly loaded in the classpath, or maybe you are mixing versions and class names may be different (or it's behavior). Check if the Digester jar you are adding is the one that is needed.

Check if these jar are correctly loaded:

jasperreports-.jar;
jasperreports-javaflow.jar;
commons-beanutils.jar;
commons-collections.jar;
commons-logging.jar;
commons-digester.jar

Take a look on jasper report plugin folder under your eclipse instance. Search for the commons digester jar inside this folder and copy the same jar (and the other of listed jars) in your project.