Jasper Reports:子报告导致无限循环 [英] Jasper Reports : sub-reports are causing an infinite loop
问题描述
我的应用程序中有多个 Jasper Reports (带子报告)。出于某种原因,一份报告(也包含子报告)不再起作用。调试超过1天后,我发现它进入了一个无限循环并继续为子报表填充创建线程。
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.
调试器保持循环:
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;
}
上述方法启动一个线程以填充子报告。完成后,设置 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();
}
}
一旦线程完成,它就会转到上面的方法 subreportFiller.notifyAll();
line。然后,调试器返回 JRSubreportRunnable.java ,依此类推。
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.
理论上,如果我有5个子报告,它应该创建5个线程(适用于其他报告)。不幸的是,对于这种情况,它不断创建线程,我的调试器在上面提到的两种方法之间卡住(仅供参考:类来自 jasperreports-3.7.6-sources.jar )。
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).
也尝试过:
我发现类似StackOverflow问题,但那里提出的答案对我不起作用。 JasperSoft社区的这个主题中没有提出任何建议的解决方案。
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.
我真的无法理解为什么会出现这个问题。我确信这是一个很小的东西,因为它曾经工作过。希望其他人偶然发现这个并且可能有解决方案。提前感谢您的回答。 (我知道我没有提供关于我的子报告内容的真正信息,但它非常隐私;不过,我可以向你保证报告的内容和相关的子报告没有改变 - 用Git检查)
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)
推荐答案
我有完全相同的问题并通过将子报表的isPrintWhenDetailOverflows属性从true更改为false来解决它
如下所示:
http://community.jaspersoft。 com / questions / 527078 / infinite-loop-subreport-fill
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
希望有所帮助
这篇关于Jasper Reports:子报告导致无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!