Frage

I have a web app that uses JasperReports to power data export to Excel, PDF & CSV. It's a grails app using the DynamicJasperReports plugin and it uses a jrxml file as the template for the report.

This was working but has broken following some changes to our tomcat configuration. It still works locally in grails development mode.

FastReportBuilder drb = new FastReportBuilder()
drb.setTemplateFile("resources/reportTemplate.jrxml")

DynamicReport report = reportBuilder.call(drb)

JRDataSource ds = new JRMapCollectionDataSource(data)

JasperPrint jp = DynamicJasperHelper.generateJasperPrint(report, new ClassicLayoutManager(), ds)
ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(jp, format, [:])
reportWriter.writeTo(response)

It throws this error:

java.lang.NullPointerException
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperDesign(DynamicJasperHelper.java:151)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:448)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:234)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:187)
at com.giivpro.services.analytics.JasperReportsService.runReport(JasperReportsService.groovy:30)

Keine korrekte Lösung

Andere Tipps

I eventually realized this was not due to upgrading to tomcat7 as I originally thought but instead was due to changes in how the app was being deployed, made around the same time.

All the jar file dependencies of the app are now copied to /var/lib/tomcat/lib rather than being deployed inside the war file. Which means that the line in DynamicJasperHelper

URL url = DynamicJasperHelper.class.getClassLoader().getResource(dr.getTemplateFileName());

now failed due to security restrictions on the ClassLoader. The jars in /var/lib/tomcat/lib get loaded by a separate ClassLoader and are not able to load resources from specific WAR files.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top