加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Jasper Reports:子报告导致无限循环

发布时间:2020-12-14 19:22:09 所属栏目:Java 来源:网络整理
导读:我的应用程序中有多个Jasper Reports(包含子报告).出于某种原因,一份报告(也包含子报告)不再起作用.调试超过1天后,我发现它进入无限循环并继续创建用于子报告填充的线程. 调试器保持循环: JRSubReportRunnable.java public void run(){ running = true; err

我的应用程序中有多个Jasper Reports(包含子报告).出于某种原因,一份报告(也包含子报告)不再起作用.调试超过1天后,我发现它进入无限循环并继续创建用于子报告填充的线程.

调试器保持循环:

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;
}

上面的方法启动一个Thread以填充子报告.完成后,设置running = false并且调试器将:

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();线.然后,调试器返回到JRSubreportRunnable.java,依此类推.

从理论上讲,如果我有5个子报告,它应该创建5个线程(适用于其他报告).不幸的是,对于这种情况,它不断创建线程,我的调试器在上面提到的两种方法之间“卡住”(仅供参考:类来自jasperreports-3.7.6-sources.jar).

还尝试过:

我找到了一个similar StackOverflow question,但提出的答案对我来说没有用.从this thread on the JasperSoft Community开始,任何提议的解决方案都没有.

我真的无法理解为什么会出现这个问题.我确信这是一个很小的东西,因为它曾经工作过.希望其他人偶然发现这个并且可能有解决方案.提前感谢您的回答. (我知道我没有提供关于我的子报告内容的真正信息,但它非常隐私;不过,我可以向你保证报告的内容和相关的子报告没有改变 – 用Git检查)

最佳答案
我有完全相同的问题,并通过将子报表的isPrintWhenDetailOverflows属性从true更改为false来解决它
如下所示:
http://community.jaspersoft.com/questions/527078/infinite-loop-subreport-fill

希望能帮助到你

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读