java.lang.ClassNotFoundException: org.apache.commons.digester.Rule

Krish

This is not a new question, but Im help/clue less... so asking it here... Im getting the error "java.lang.ClassNotFoundException: org.apache.commons.digester.Rule" when Im trying to run a DynamicReport sample project. My specifications are below: Java - 1.7,commons-beanutils-1.9.3,commons-collections-3.2.2,commons-digester-3.2,commons-lang-3.7,commons-logging-1.2,dynamicreports-core-5.0.0,jasperreports-5.6,jasperreports-javaflow,

code snippet is below:

// import statements
public class sampleReport {

public sampleReport() {
    build();
}

private void build() {

    try {
        JasperReportBuilder report = DynamicReports.report();
        // a new report
        report // create new report design
            .columns(
                // add columns title, field name data type
                Columns.column("Item", "item",
                    DataTypes.stringType()),
                Columns.column("Quantity", "quantity",
                    DataTypes.integerType()),
                Columns.column("Unit price",
                    "unitprice",

                    DataTypes.bigDecimalType()))

            .title(Components.text("Getting started report")

                .setHorizontalAlignment(HorizontalAlignment.CENTER))
            // shows report title
            .pageFooter(Components.pageXofY())
            // shows number of page at page footer
            .setDataSource(createDataSource())
            // set datasource
            .show(); // create and show report

        // show the report
        report.show();

        // export the report to a pdf file
        report.toPdf(new FileOutputStream("c:/report.pdf"));

    } catch (DRException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

}

private JRDataSource createDataSource() {

    DRDataSource dataSource = new DRDataSource("item",
        "quantity", "unitprice");
    dataSource.add("Notebook", 1, new BigDecimal(500));
    dataSource.add("DVD", 5, new BigDecimal(30));
    dataSource.add("DVD", 1, new BigDecimal(28));
    dataSource.add("DVD", 5, new BigDecimal(32));
    dataSource.add("Book", 3, new BigDecimal(11));
    dataSource.add("Book", 1, new BigDecimal(15));
    dataSource.add("Book", 5, new BigDecimal(10));
    dataSource.add("Book", 8, new BigDecimal(9));

    return dataSource;
}

public static void main(String[] args) {
    new sampleReport();
}

Any help is appreciated.

Aristotelis Margaris

I am not aware of your IDE configuration and / or build configuration. However the error is pointing me into the direction of a jar version incompatibility issue. Basically what happens is that one of your jars is referencing a class that is not included in the current build path due to different version (older or newer)

Suggested Solution: If you have the capability of using a more advanced build tool like maven or gradle, it will automatically resolve the dependencies and can point out issues with the version. The best way to use them is to add the maven artifacts one by one (starting from the most complex-dependant jar) until all import errors are removed. This will probably fix all the version issues.

Alternative (FAST) Solution: download this version of apache.digester because if you look at the maven dependencies of jasper you can see that it references version 2.1 of digester whereas you are using version 3.2 which probably has the same class under a different package.

Hope it helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

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

I am getting java.lang.NoClassDefFoundError: org/apache/commons/digester/Rule error

java.lang.ClassNotFoundException: org.apache.commons.lang.UnhandledException

org.apache.commons.lang.SerializationException: java.lang.ClassNotFoundException

java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory

java.lang.ClassNotFoundException: org.apache.commons.text.WordUtils

java.lang.ClassNotFoundException: org.apache.commons.logging.Log

java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader

Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.builder.EqualsBuilder

java.lang.ClassNotFoundException: org.apache.commons.lang.builder.ToStringBuilder

Error: java.lang.ClassNotFoundException: org.apache.commons.collections4.map.LinkedMap

Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils

java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64

Exception: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

How to fix 'org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException' in quarkus native image

Maven - ClassNotFoundException: org.apache.commons.lang.StringUtils

Java - Apache commons Digester - write xml

Apache Commons Configuration: ClassNotFoundException: org.apache.commons.beanutils.DynaBean

java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer

How to use org.apache.commons.lang namespace in Java?

java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils

java.lang.AbstractMethodError: org.apache.commons.dbcp.PoolingDataSource

java.lang.ClassNotFoundException: org.apache.spark.sql.Dataset

java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException

java.lang.ClassNotFoundException: org.apache.pdfbox.multipdf.PDFMergerUtility

java.lang.ClassNotFoundException: org.apache.catalina.core.ThreadLocalLeakPreventionListener

java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject Error

java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver

java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.isBlank(Ljava/lang/String;)Z Error