【问题标题】:Jasper Reports : sub-reports are causing an infinite loopJasper 报告:子报告导致无限循环
【发布时间】:2012-10-18 12:21:13
【问题描述】:

我的应用程序中有多个 Jasper 报告(带有子报告)。出于某种原因,一份报告(也包含子报告)不再起作用。调试了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;
}

上述方法启动一个线程以填充子报告。完成后,设置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 检查)

【问题讨论】:

  • 感谢您的反对。您能否发表评论,解释为什么您对帖子投了反对票?

标签: java jasper-reports


【解决方案1】:

我遇到了完全相同的问题,并通过将我的子报表的 isPrintWhenDetailOverflows 属性从 true 更改为 false 来解决它 如此处建议: http://community.jaspersoft.com/questions/527078/infinite-loop-subreport-fill

希望对你有帮助

【讨论】:

  • 感谢您的回复。老实说,我试过了,我尝试了所有在 SO 和 JasperSoft 社区上能找到的与此相关的东西,但它对我不起作用。目前,这个问题被认为不是我的项目的优先事项,所以我已经停止(一段时间)查看它。不过,如果有人提出了一些我没有找到的解决方案,我会查看它们。提前致谢!
  • 这对我有用,所以肯定有一些不同的场景,但由于这篇文章是 4 年前的,所以这并不重要,只是说它在某些情况下有效 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-30
相关资源
最近更新 更多