DynamicJasper:如何修复 java.lang.NoSuchMethodError 错误

发布于 2025-01-07 05:11:52 字数 3078 浏览 2 评论 0原文

我有一个动态碧玉报告的例子。

我正在使用 NetBeans IDE。

我包含库文件如下:

Dynamic-jasper-3.2.1.jar
Dynamic-jasper-3.2.1-test.jar
jasperreport-4.5.jar
commons-beanutils-1.8.2.jar 
commons-collections-3.2.1.jar 
commons-digester-1.7.jar 
commons-logging-1.1.jar 
junit-3.8.2.jar
import java.util.Date;
import net.sf.jasperreports.view.JasperDesignViewer;
import net.sf.jasperreports.view.JasperViewer;
import ar.com.fdvs.dj.domain.DynamicReport;
import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
import ar.com.fdvs.dj.test.BaseDjReportTest;

public class FastReportTest extends BaseDjReportTest {
    public DynamicReport buildReport() throws Exception {

        FastReportBuilder drb = new FastReportBuilder();
        drb.addColumn("State", "state", String.class.getName(), 30)
                .addColumn("Branch", "branch", String.class.getName(), 30)
                .addColumn("Product Line", "productLine", String.class.getName(), 50)
                .addColumn("Item", "item", String.class.getName(), 50)
                .addColumn("Item Code", "id", Long.class.getName(), 30, true)
                .addColumn("Quantity", "quantity", Long.class.getName(), 60, true)
                .addColumn("Amount", "amount", Float.class.getName(), 70, true)
                .addGroups(2)
                .setTitle("November \"2006\" sales report")
                .setSubtitle("This report was generated at " + new Date())
                .setPrintBackgroundOnOddRows(true)
                .setUseFullPageWidth(true);

        DynamicReport dr = drb.build();
        return dr;
    }

    public static void main(String a[]) throws Exception {
        FastReportTest test = new FastReportTest();
        // test.
        test.testReport();
        test.exportToJRXML();
        JasperViewer.viewReport(test.jp);    //finally display the report report
        JasperDesignViewer.viewReportDesign(test.jr);
    }
}

我遇到这样的错误:

Feb 17, 2012 10:30:58 AM ar.com.fdvs.dj.core.DynamicJasperHelper generateJasperReport
INFO: generating JasperReport
Feb 17, 2012 10:30:58 AM ar.com.fdvs.dj.core.DynamicJasperHelper generateJasperReport
INFO: generating JasperReport
Feb 17, 2012 10:30:58 AM ar.com.fdvs.dj.core.DJJRDesignHelper getNewDesign
INFO: obtaining DynamicJasperDesign instance
Exception in thread "main" java.lang.NoSuchMethodError: ar.com.fdvs.dj.domain.DynamicJasperDesign.setPrintOrder(B)V
    at ar.com.fdvs.dj.core.DJJRDesignHelper.getNewDesign(DJJRDesignHelper.java:69)
    at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperDesign(DynamicJasperHelper.java:207)
    at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:535)
    at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:518)
    at ar.com.fdvs.dj.test.BaseDjReportTest.testReport(BaseDjReportTest.java:83)
    at FastReportTest.main(FastReportTest.java:34)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

I have a example for dynamic jasper report.

I am using NetBeans IDE.

I include library files as follows :

Dynamic-jasper-3.2.1.jar
Dynamic-jasper-3.2.1-test.jar
jasperreport-4.5.jar
commons-beanutils-1.8.2.jar 
commons-collections-3.2.1.jar 
commons-digester-1.7.jar 
commons-logging-1.1.jar 
junit-3.8.2.jar
import java.util.Date;
import net.sf.jasperreports.view.JasperDesignViewer;
import net.sf.jasperreports.view.JasperViewer;
import ar.com.fdvs.dj.domain.DynamicReport;
import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
import ar.com.fdvs.dj.test.BaseDjReportTest;

public class FastReportTest extends BaseDjReportTest {
    public DynamicReport buildReport() throws Exception {

        FastReportBuilder drb = new FastReportBuilder();
        drb.addColumn("State", "state", String.class.getName(), 30)
                .addColumn("Branch", "branch", String.class.getName(), 30)
                .addColumn("Product Line", "productLine", String.class.getName(), 50)
                .addColumn("Item", "item", String.class.getName(), 50)
                .addColumn("Item Code", "id", Long.class.getName(), 30, true)
                .addColumn("Quantity", "quantity", Long.class.getName(), 60, true)
                .addColumn("Amount", "amount", Float.class.getName(), 70, true)
                .addGroups(2)
                .setTitle("November \"2006\" sales report")
                .setSubtitle("This report was generated at " + new Date())
                .setPrintBackgroundOnOddRows(true)
                .setUseFullPageWidth(true);

        DynamicReport dr = drb.build();
        return dr;
    }

    public static void main(String a[]) throws Exception {
        FastReportTest test = new FastReportTest();
        // test.
        test.testReport();
        test.exportToJRXML();
        JasperViewer.viewReport(test.jp);    //finally display the report report
        JasperDesignViewer.viewReportDesign(test.jr);
    }
}

I have Got error like this :

Feb 17, 2012 10:30:58 AM ar.com.fdvs.dj.core.DynamicJasperHelper generateJasperReport
INFO: generating JasperReport
Feb 17, 2012 10:30:58 AM ar.com.fdvs.dj.core.DynamicJasperHelper generateJasperReport
INFO: generating JasperReport
Feb 17, 2012 10:30:58 AM ar.com.fdvs.dj.core.DJJRDesignHelper getNewDesign
INFO: obtaining DynamicJasperDesign instance
Exception in thread "main" java.lang.NoSuchMethodError: ar.com.fdvs.dj.domain.DynamicJasperDesign.setPrintOrder(B)V
    at ar.com.fdvs.dj.core.DJJRDesignHelper.getNewDesign(DJJRDesignHelper.java:69)
    at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperDesign(DynamicJasperHelper.java:207)
    at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:535)
    at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:518)
    at ar.com.fdvs.dj.test.BaseDjReportTest.testReport(BaseDjReportTest.java:83)
    at FastReportTest.main(FastReportTest.java:34)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

西瑶 2025-01-14 05:11:52

如果您使用的是 DynamicJasper 3.2.1,您应该使用 DJ 的 pom.xml 中的外部库。

pom.xml 文件的片段:

<dependencies>
    <dependency>
        <groupId>jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>3.7.1</version>
        <exclusions>
            <exclusion>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>bouncycastle</groupId>
                <artifactId>bcmail-jdk14</artifactId>
            </exclusion>
            <exclusion>
                <groupId>bouncycastle</groupId>
                <artifactId>bcprov-jdk14</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.1</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.7.0</version>
    </dependency>
    <dependency>
        <groupId>opensymphony</groupId>
        <artifactId>xwork</artifactId>
        <version>1.2.1</version>
        <scope>provided</scope>
       <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>opensymphony</groupId>
        <artifactId>webwork</artifactId>
        <version>2.2.4</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.3</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.sourceforge</groupId>
        <artifactId>barbecue</artifactId>
        <version>1.1</version>
        <optional>true</optional>
    </dependency>
</dependencies>

如您所见,此版本 (3.2.1) 的 DJ API 使用 jasperreports 3.7.1 等。

In case you are using the DynamicJasper 3.2.1 you should use the externals libraries from the DJ's pom.xml.

The snippet of the pom.xml file:

<dependencies>
    <dependency>
        <groupId>jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>3.7.1</version>
        <exclusions>
            <exclusion>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>bouncycastle</groupId>
                <artifactId>bcmail-jdk14</artifactId>
            </exclusion>
            <exclusion>
                <groupId>bouncycastle</groupId>
                <artifactId>bcprov-jdk14</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.1</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.7.0</version>
    </dependency>
    <dependency>
        <groupId>opensymphony</groupId>
        <artifactId>xwork</artifactId>
        <version>1.2.1</version>
        <scope>provided</scope>
       <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>opensymphony</groupId>
        <artifactId>webwork</artifactId>
        <version>2.2.4</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.3</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.sourceforge</groupId>
        <artifactId>barbecue</artifactId>
        <version>1.1</version>
        <optional>true</optional>
    </dependency>
</dependencies>

As you can see this version (3.2.1) of DJ API is using jasperreports 3.7.1 and etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文