1
votes

i have a jasperreport with some subreports. I want to store the .jasper files inside the classpath.

Actually my reports are in com/myapp/reports.

I can successufly load the main report with this path:

    private static String D1_PACKAGE = "/com/myapp/report/d1.jasper";
...
    InputStream reportD1 = ReportProvider.class.getResourceAsStream(D1_PACKAGE);
    bytes = JasperRunManager.runReportToPdf(reportD1, params, new JREmptyDataSource());

But the problem is when it looks for subreports. They are in the folder but i tried to change the param SUBREPORT_DIR with one of these path but no one works:

./
/com/myapp/report
com/myapp/report
1
I found this: stackoverflow.com/questions/4825726/… I should have passed subreports as mainreport paramsTobia

1 Answers

0
votes

I should load the subreports with class.getResourceAsStream than pass it as parameter to the main report.