com.hughes.exception.HughesException at com.hughes.service.serviceImpl.HomeServiceImpl.sendTicketEmail(HomeServiceImpl.java:1094) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ....................................................... .......................................... Caused by: net.sf.jasperreports.engine.JRException: Resource not found at : nullinvoiceDetail.jasper at net.sf.jasperreports.repo.RepositoryUtil.getResource(RepositoryUtil.java:155) at net.sf.jasperreports.repo.RepositoryUtil.getReport(RepositoryUtil.java:126) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateReport(JRFillSubreport.java:317) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:347) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:275) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:473) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2021) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:755) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:265) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:765) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624) at com.hughes.service.serviceImpl.HomeServiceImpl.sendTicketEmail(HomeServiceImpl.java:1046) ... 81 more
JasperReport jasperReport = JasperCompileManager.compileReport(hdnWebInfPath+seperator+"reports"+seperator+"invoice.jrxml");
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, model, new JREmptyDataSource());
JasperExportManager.exportReportToPdfFile(jasperPrint, fPath+seperator+fileName);
this works when simple report not working for sub reports...
My Jarper knowledge is couple versions old, but lets hope this is helpful.
This is because jasper does not find your subreport. Jasper can compile your report, but it does not compile referenced subreports when you call
compileReport
. When filling the report referenced subreports are not found because they are not available in working directory.(Compiling report every time it is requested is kind a bad idea (unless you have some really heavy reasons to do so).)
There are couple of ways solving this. One would be making sure the the paths are correct and precompiling the reports before application deployment. Links Alex K provided are an excellent source for this. If in application compilation is required then using solution below is possible:
In web application I've found that a working practice is to handle compilation and filling your reports is to manage it manually. Here is helper class I wrote. Hope that it is useful (it uses spring, but those parts are easily replaceable).
With the help of this class you can refer subreports in documents like this:
Here
$P{data}
is suitable object provided as document parameter, wheregetSubreport()
ends up callingReportSource.getReport()
. It could of course be$P{reportSource}.getReport("....")
ifReportSource
is provided as parameter directly. (We use ReportModel-approach; in short it is presentation model fitted to the context of reports).