Search code examples
javajasper-reports

IReport - Subreport as Inputstream parameter


I have a Subreport, that works well, and I have a another report that is using the Subreport and also works well in the IReport; always that I use the subreport from "file Path".

But, I want to add the reports in a JAR (OSGI Bundle), and will execute the report using InputStream to load the Jasper Reports.

Using IReport Designer(version 5.6.0), The Tool to design the Report, is giving me a "Warning" when I change from "File Path" to "Inputstream" in the SubReport Expression Property.

The warning is:

Unable to locate the subreport with expression: "$P{SUBREPORT_1}".

What is the best way to run the report using IReport?


Solution

  • This warning just means that iReport is trying to compile the subreport, but can't find it.

    When you were using "File Path", you could put the full path to the subreport file, and iReport would find it.

    Since you changed to an InputStream, iReport doesn't know how to find the subreport to compile it.

    When the report runs inside your application, though, you will feed that information as a parameter and it will run normally.

    If you want to stop that warning, just disable the compilation of subreports. Go to Tools, Options, iReport, Compilation and Execution and untick the option labeled "Compile Subreports (if can be found)".