Subreport rendering

0

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.
andrew.bengier's picture
Joined: Feb 23 2016 - 7:05am
Last seen: 2 years 4 months ago

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.

andrew.bengier - 2 years 4 months ago

subreport = templateUtil.getJasperSubReportTemplate( reportName )

so subreport is not path

comment is unclear

sanbez - 2 years 4 months ago
show 2 more...

Sorry for the confusion - getJasperSubReportTemplate returns a byte[] for the template. 

andrew.bengier - 2 years 4 months ago

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.

Ghassan1993 - 2 years 4 months ago

0 Answers:

No answers yet
Feedback
randomness