I have a java rest service that returns a generated PDF out of a jasper file. For some bussiness rules, the compiled .jasper files will not be on the service, only the .jxrml files. I compile the report at runtime using this line
JasperReport report = JasperCompileManager.compileReport(fileName);
This is the original section of the subreport with the reference to the compiled .jasper file
<subreport isUsingCache="false">
<reportElement x="57" y="30" width="498" height="15" isRemoveLineWhenBlank="true" uuid="5b26c250-7d4d-4ddb-9fdc-834a98fc6eac"/>
<subreportParameter name="fecha">
<subreportParameterExpression><![CDATA[$F{recorridodato_Fecha}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="idRuta">
<subreportParameterExpression><![CDATA[$F{ruta_RutaId}.longValue()]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "subreport.jasper"]]></subreportExpression>
</subreport>
This is what I read somewhere (I can't remember where) that I should do
<subreport isUsingCache="false">
<reportElement x="57" y="30" width="498" height="15" isRemoveLineWhenBlank="true" uuid="5b26c250-7d4d-4ddb-9fdc-834a98fc6eac"/>
<subreportParameter name="fecha">
<subreportParameterExpression><![CDATA[$F{recorridodato_Fecha}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="idRuta">
<subreportParameterExpression><![CDATA[$F{ruta_RutaId}.longValue()]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[JasperCompileManager.compileReport(getClass().getResource($P{SUBREPORT_DIR} + "subreport.jrxml").openStream())]]></subreportExpression>
</subreport>
The second options works when the report is called from within iReport. Howhever, it fails when called from the service. The generated PDF does not print the subreport data. The first option works OK both on iReport and on the REST service call, but it references the compiled .jasper file, which will not be accesible. So I need to generate the global report in Java by referencing the .jrxml subreport path only (not the .jasper file) I am using these maven references
<!-- Jasper-->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.6.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>