Jump to content
Changes to the Jaspersoft community edition download ×

Subreport rendering


Recommended Posts

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();}[/code]
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.
Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Read that one... Thats why i tried adding 

dataModel.put( "SUBREPORT", subreport );[/code]

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...