IReport: Error when compiling report with subreport

ireportjasper-reports

The following .jrxml:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="DTC-Campaigns-Block-Campaigns-Helper-Campaigns" language="groovy" pageWidth="794" pageHeight="450" orientation="Landscape" columnWidth="794" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
    <queryString><![CDATA[SELECT 1;]]></queryString>
    <detail>
        <band height="50" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="794" height="25"/>
                <subreportExpression class="java.lang.String"><![CDATA["./test.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>

won't compile within iReport 3.6.0:

Compiling to file... /home/dominik/workspace/project1/reporting/MyFile.jasper
Compiling subreports....
Unable to locate the subreport with expression: "$P{SUBREPORT_DIR} + "test.jasper"".

Even fixing SUBREPORT_DIR to ./ won't help, neither will compiling test.jrxml manually before the master report.

Any ideas?

Best Answer

In the jrxml extract, you do not specify that SUBREPORT_DIR is a String parameter... You might add this information.

I also notice a change of behaviors between version 3.5.2 and 3.5.3 Changelog of version 3.5.3 says :

Automatic compilation of subreports

As a consequence parametrize subreport path do not seems to work any longer... (but I remembered getting a warning, and not a fail).

Have you tried :

  • To compile only the subreport (using iReport). [a preview will produce the jasper file which is the compiled version of the jrxml]
  • To give an expression with the jrxml file (instead of the jasper file) $P{SUBREPORT_DIR} + "test.jrxml", and without a parameter at all (like "test.jrxml" -- your subreport needs to be in the same local directory as your main report)
Related Topic