0

我正在尝试将JasperReports jrxml 模板加载到我的DynamicReport对象,但我得到一个空指针,但不知道它来自哪里。

代码实际上是这样的:

DynamicReport dr = new DynamicReport();
DynamicReportBuilder drb = new DynamicReportBuilder();
......
drb.setTemplateFile("styles/myreport.jrxml");
dr = drb.build();

然后我打电话

 JasperPrint jp = DynamicJasperHelper.generateJasperPrint(dr, new ClassicLayoutManager(), resultSetDataSource);

错误是这样的:

java.lang.NullPointerException
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperDesign(DynamicJasperHelper.java:200)
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.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:283)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:236)

有人知道吗?

ps:我正在使用iReport 5(甚至尝试使用 4)和DynamicJasper 3.1.8

4

1 回答 1

1

DynamicJasper 和 JasperReport 需要相互兼容,我认为这是你的问题。

请找到以下兼容性:

DJ 5.x works with JasperReposrts 4.6+ (and 5.0+, 5.1+ and 5.2) and needs JDK 1.6
DJ 4.x workrs with JasperReports 4.1 to 4.5.x
DJ 3.0.5 works with JR 3.5 up to 4.0

注意:确保您jrxml使用Jasper版本编译。

于 2014-02-27T11:08:16.600 回答