So i have a jasper report that contains a subreport. When i run it in iReport or JasperStudios ( i have two versions one with uuid's and one legacy but otherwise the same ) it works. When i add the reports, main and subreport to my java I am getting the following -
net.sf.jasperreports.engine.JRException: Resource not found at: ./Subreport.jasper.
I am filling the report:
//JasperReportModel Class private Map<String, Object> mpModel; private String jsonArray; private String jasperTplPath; private String format; private byte[] jasperTemplate; //Service classJasperReportModel jasperReportModel = getJasperReportModel( dataModel, reportName, jsonArray, format );byte[] report = generateReport( jasperReportModel ); private JasperReportModel getJasperReportModel( Map<String, Object> dataModel, String reportName, JSONArray jsonData, String format ) { try { jasperTemplate = getJasperTemplateByteArray( reportName, format ); subreport = templateUtil.getJasperSubReportTemplate( reportName ); if( subreport != null ) { dataModel.put( "SUBREPORT", subreport ); } JasperReportModel jRptModel = new JasperReportModel( reportModel, jsonData.toString(), jasperTemplate, format ); return jRptModel; } catch( IOException e ) { e.printStackTrace(); throw new RuntimeExcaption(); }} private byte[] generateReport( JasperReportModel jrptModel ) { map<String, Object> mpReportModel = jrptModel.getMpModel(); JsonDataSource jsonDataSource = new JsonDataSource( jrptModel.getJsonArray() ); mpReportModel.put( "REPORT_DATA_SOURCE", jsonDataSource ); JasperPrint jasperPrint = JasperFillManager.fillReport( jasperTemplate, mpReportModel ); jasperPrint.toByteArray();}
Can someone tell me why i am getting a resource not found error if my .jasper and .jrxml files are all in the same folder. The only things that's not in that folder are JRM class and the service class.
0 Answers:
No answers yet
http://stackoverflow.com/questions/18656016/jasperreports-cant-locate-su...
Read that one... Thats why i tried adding
dataModel.put( "SUBREPORT", subreport );
Thanks though, I am going to try a workaround for now. I will try ot run both the main report and subreport separately and for pdf stitch them together and for excel see if the requirements allow me to make separate sheets.
subreport = templateUtil.getJasperSubReportTemplate( reportName )
so subreport is not path
comment is unclear
Sorry for the confusion - getJasperSubReportTemplate returns a byte[] for the template.
Dear Sir,
click on the subreport in your Master Report:
in the properties left window go to "Subrport Expression":
Error Cause:
SubReport Path is wrong.
Best Regards,
Ghassan Nafash.