Sub-subReport execution returns “java.lang.OutOfMe

2019-09-08 11:29发布

问题:

Here's my problem: I have a JasperReport (mainReport) with one subreport (subReport) which, at the same time, have one subreport (subSubReport). My problem comes when I try to execute it from my web app. Those reports are extracted from an Oracle database, thus I'm passing an InputStream as "path" for them.

Since I've been testing "paths" as InputStream (obtained from the same database) I know it works when I have a simple mainReport->subReport hierachy... that's why I'm pretty sure the problem lies in the way I'm passing the parameters to the subSubReport.

Since now if I wanted to pass some parameter (as the path) to the subReport it has to be defined in the mainReport (also passed to the mainReport as a parameter) and it had to be passed as a parameter from the mainReport to the subReport. For that reason, I'm pasing all the parameters, even those needed for the subSubReports to the mainReport (and I'm guessing that's not the correct way since I'm getting java.lang.OutOfMemoryError: GC overhead limit exceeded when executing).

I'm following the next format to define where each one of my parameters has to go:

  • SUBREPORT_DIR for those reports that are stored in a local folder.

  • SUBREPORTxLEVELy for those reports that are in the database.

Where:

x defines the number of the subReport according to its position (the band where it is) in the mainReport

y defines the level where the parameter is necessary (in this case subReport is in level 1 while subSubReport is in level 2)

For example:

Having such a hierarchy I'm coding it the following way:

Problematic hierarchy

mainReport

------------> subReport

-------------------------> subSubReport

Note that I defined SUBREPORT_DIR and SUBREPORTxLEVELy because the report can either be found in a local folder or at the database and in my jasper design I have this expression for the subreports IF($P{SUBREPORT_DIR}==null,$P{SUBREPORTxLEVELy},$P{SUBREPORT_DIR}) .

Here is the code used in each report and the java code to generate the report.

mainReport

<subreport>
        <reportElement key="" x="0" y="0" width="554" height="30" isRemoveLineWhenBlank="true" uuid="18ff5513-835d-4910-b39c-6d41252b4679"/>
<subreportParameter name="REPORT_CONNECTION">
<subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="REPORT_DATA_SOURCE">
<subreportParameterExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="SUBREPORT1LEVEL1">
<subreportParameterExpression><![CDATA[$P{SUBREPORT1LEVEL1}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="SUBREPORT1LEVEL2">
<subreportParameterExpression><![CDATA[$P{SUBREPORT1LEVEL2}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[IF($P{SUBREPORT_DIR}==null,$P{SUBREPORT1LEVEL1},$P{SUBREPORT_DIR})]]></subreportExpression>
</subreport>

subReport

<subreport>

<reportElement x="50" y="10" width="457" height="40" uuid="4528914e-bb9a-4300-8173-14be2ff2db85"/>

<subreportParameter name="REPORT_CONNECTION">

        <subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression>

</subreportParameter>

<subreportParameter name="REPORT_DATA_SOURCE">

<subreportParameterExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></subreportParameterExpression>

</subreportParameter>

<subreportParameter name="SUBREPORT_DIR">

         <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>

        </subreportParameter>

<subreportParameter name="SUBREPORT1LEVEL2">

<subreportParameterExpression><![CDATA[$P{SUBREPORT1LEVEL2}]]></subreportParameterExpression>

</subreportParameter>

<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>

<subreportExpression><![CDATA[IF($P{SUBREPORT_DIR}==null,$P{SUBREPORT1LEVEL2},$P{SUBREPORT_DIR})]]></subreportExpression>

</subreport>

java code

parameters.put("SUBREPORT1LEVEL1", inputStream1); (For subReport) parameters.put("SUBREPORT1LEVEL2", inputStream2); (For subSubReport)

Didn't find necessary to post the rest of the Java code 'cause I know it works how it's supposed to.

The three reports compile perfectly in the designer (each one separated) generating the .jasper file correctly.

So, my questions being said:

  • What am I doing wrong?
  • How am I supposed to pass the parameters to define the report path for a subSubReport?
  • Does the parameter need to be passed to the mainReport as I do when I have a subReport?

In conclusions, I want to be able to asign the correct InputStream to each subReport/subSubReport, which one is the better (and known) way to do it?

Thanks a lot!

Question asked at: http://community.jaspersoft.com/questions/1042586/sub-subreport-execution-returns-javalangoutofmemoryerror-gc-overhead-limit