Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasper Reports : sub-reports are causing an infinite loop

I have multiple Jasper Reports (with sub-reports) throughout my application. For some reason, one report (that also contains sub-reports) isn't working anymore. After debugging more than 1 day, I found out that it enters an infinite loop and keeps creating Threads for sub-report filling.

Debugger keeps looping between:

JRSubReportRunnable.java

public void run()
{
    running = true;     
    error = null;

    try
    {
        fillSubreport.fillSubreport();
    }
    catch (JRFillInterruptedException e)
    {
        //If the subreport filler was interrupted, we should remain silent
    }
    // we have to catch Throwable, because it is difficult to say what would happen with the master
    // filler thread in case we don't
    catch (Throwable t) //NOPMD
    {
        error = t;
    }

    running = false;
}

The above method starts a Thread in order to fill a sub-report. Once done, sets running = false and the debugger gets to:

JRThreadSubreportRunner.java

public void run()
{
    super.run();

    if (log.isDebugEnabled())
    {
        log.debug("Fill " + subreportFiller.fillerId + ": notifying of completion");
    }

    synchronized (subreportFiller)
    {
        //main filler notified that the subreport has finished
        subreportFiller.notifyAll();
    }
}

Once the thread finishes, it gets to the above's method subreportFiller.notifyAll(); line. Then, the debugger goes back to JRSubreportRunnable.java, and so on.

Theoretically, if I have 5 sub-reports, it should create 5 threads (works for me for other reports). Unfortunately, for this case, it keeps creating threads, and my debugger gets "stuck" between the 2 methods mentioned above (FYI: the classes are from the jasperreports-3.7.6-sources.jar).

Also tried:

I found a similar StackOverflow question, but the answer proposed there did not work for me. Neither did any of the proposed solutions from this thread on the JasperSoft Community.

I really cannot figure why this issue appears. I am sure it is something minor as it used to work. Hopefully someone else stumbled upon this and might have a solution. Thanks in advance for any answer. (I know I haven't provided really much info about the content of my sub-reports, but it is pretty private; nevertheless, I can assure you that the contents of the report and associated sub-reports did not change - checked with Git)

like image 952
Raul Rene Avatar asked Oct 18 '12 12:10

Raul Rene


1 Answers

I had the exact same problem and solved it by changing the isPrintWhenDetailOverflows property of my subreport from true to false as suggested here: http://community.jaspersoft.com/questions/527078/infinite-loop-subreport-fill

hope it helps

like image 199
Flo Avatar answered Oct 19 '22 04:10

Flo