简体   繁体   English

Jaspersoft 报告,“异常:java.lang.OutOfMemoryError 从线程“BAM 子报告 #1”中的 UncaughtExceptionHandler 引发

[英]Jaspersoft reports, “Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread ”BAM subreports #1“”

I have a simple Jasper report, that I simplified it at maximum and now it should give me a blank page but instead it gives me a "Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "BAM subreports #1"".我有一个简单的 Jasper 报告,我最大程度地简化了它,现在它应该给我一个空白页,但它给了我一个“异常:java.lang.OutOfMemoryError 从线程“BAM 子报告 #1”中的 UncaughtExceptionHandler 引发的错误。

Jasper takes a long time to think and in the end displays the memory error. Jasper想了很久,最终显示memory错误。

The blockage that causes the supposed memory leak appears in the JasperFillManager.fillReport.导致假定的 memory 泄漏的阻塞出现在 JasperFillManager.fillReport 中。

This is no a problem related to the allocated memory, I tried to increase the memory with the options "-Xms1140m -Xmx1140m" and it seems to think forever for a very simple report.这与分配的 memory 无关,我尝试使用选项“-Xms1140m -Xmx1140m”来增加 memory,它似乎永远为一个非常简单的报告而思考。

The report contains:该报告包含:

  • a main report that contains a single element: a subreport.包含单个元素的主报表:子报表。 The main report has a single record of type BAMHeader in the JRBeanCollectionDataSource, but no element from this record is displayed on the PDF because I deleted everything hoping I will detect the cause of the problem and in the end I remained with nothing but the problem.主报告在 JRBeanCollectionDataSource 中有一条 BAMHeader 类型的记录,但此记录中没有任何元素显示在 PDF 上,因为我删除了所有内容,希望能检测到问题的原因,最后我只剩下问题了。
  • a subreport that also displays nothing and accesses his data source with the expression "new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{BAMResults})".一个也不显示任何内容并使用表达式“new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{BAMResults})”访问其数据源的子报表。 The BAMResults has a single row. BAMResults 有一行。

So the structure of the datasource is所以数据源的结构是

BAMHeader= [ <-- main report is here and contains a single record
   BAMResults= [ 
       item1, <-- for this test a single record is in BAMResults
   ]
]

The xml for the main report is:主要报告的 xml 是:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.16.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="BAM" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="13acf49e-4913-4d1b-bccc-113817ad15d1">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="BAMResults" class="java.util.List"/>
    <detail>
        <band height="192">
            <subreport overflowType="NoStretch">
                <reportElement x="2" y="150" width="530" height="30" uuid="e7898571-e6f1-4348-a3f8-2871775dd207"/>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{BAMResults})]]></dataSourceExpression>
                <subreportExpression><![CDATA["results.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>

The xml for the subreport is:子报告的 xml 是:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.16.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="results" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" uuid="34cb40f6-7f10-4c98-81fe-75101acc9691">
    <queryString>
        <![CDATA[]]>
    </queryString>
    <detail>
        <band height="72" splitType="Stretch"/>
    </detail>
</jasperReport>

The java source code of the main class is: java主class的源代码为:

public class JasperBAM {
    public static void main(String[] args) { 
        try {
            List<BAMHeader> bhs = BAMHeader.getBAMHeader();
            Map<String, Object> parameters = new HashMap<>();
            System.err.println("Start fill");
            JasperPrint jasperPrint = JasperFillManager.fillReport("JasperReports/BAM.jasper", parameters, new JRBeanCollectionDataSource(bhs));
            System.err.println("Stop fill");
            OutputStream outputStream = new FileOutputStream(new File("BAM.pdf"));
            JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
        } catch (Exception ex) {
            Logger.getLogger(JasperBAM.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

The class that will populate the main report is:将填充主报告的 class 是:

public class BAMHeader {
    private List<BAMResult> BAMResults = new ArrayList<>();
    public static List<BAMHeader> getBAMHeader() {
        try {
            List<BAMHeader> bhs = new ArrayList<>();
            BAMHeader bh = new BAMHeader();
            bh.setBAMResults();
            bhs.add(bh);
            return bhs;
        } catch (Exception ex) {
            Logger.getLogger(JasperBAM.class.getName()).log(Level.SEVERE, null, ex);
            return  null;
        }
    }

    public void setBAMResults() {
        System.err.println("Start setBAMResults");
        this.BAMResults = BAMResult.getBAMResults();
        System.err.println("Stop setBAMResults");
    }
    public List<BAMResult> getBAMResults() {
        System.err.println("Start getBAMResults");
        return this.BAMResults;
    }

}

The class that will populate the subreport is:将填充子报告的 class 是:

public class BAMResult {
    public static List<BAMResult> getBAMResults() {
        try {
            List<BAMResult> brs = new ArrayList<>();
            BAMResult nt = new BAMResult();
            brs.add(nt);
            return brs;
        } catch (Exception ex) {
            Logger.getLogger(JasperBAM.class.getName()).log(Level.SEVERE, null, ex);
            return  null;
        }
    }
}

As a final observation, if I delete the single record from BAMResults the memmory problem dissapears.作为最后的观察,如果我从 BAMResults 中删除单个记录,内存问题就会消失。

UPDATE: I use jasperreports-6.17.0.jar更新:我使用 jasperreports-6.17.0.jar

UPDATE: Apache netbeans profiler iamges更新:Apache netbeans 分析仪图像

分析线程 分析遥测

If I replace in the main report XML the line如果我在主报告中替换 XML 行

    <subreport overflowType="NoStretch">

with the line用线

    <subreport>

than the problem dissapeares.比问题消失。

But this looks like a Jasper BUG.但这看起来像 Jasper BUG。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 osx maven运行测试异常:从线程“main”中的UncaughtExceptionHandler抛出java.lang.OutOfMemoryError - osx maven running tests Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread “main” 对于超过 4GB 的文件,从线程“main”中的 UncaughtExceptionHandler 抛出的 java.lang.OutOfMemoryError - java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"’ for a file of more than 4GB 线程“main”java.lang.OutOfMemoryError中的异常 - Exception in thread “main” java.lang.OutOfMemoryError java.lang.outofmemoryerror异常? - java.lang.outofmemoryerror exception? 线程“main”中的异常 java.lang.OutOfMemoryError: Java heap space - Exception in thread “main” java.lang.OutOfMemoryError: Java heap space 2线程“ main”中的异常java.lang.OutOfMemoryError:Java堆空间 - 2 Exception in thread “main” java.lang.OutOfMemoryError: Java heap space 线程“main”中的异常java.lang.OutOfMemoryError:Java堆空间 - Exception in thread “main” java.lang.OutOfMemoryError: Java heap space 异常:java.lang.OutOfMemoryError,无法创建新的本机线程 - Exception: java.lang.OutOfMemoryError, unable to create a new native thread 如果从服务器获取大数据,则java.lang.OutOfMemoryError异常 - java.lang.OutOfMemoryError exception if getting large data from server 部署和“ java.lang.OutOfMemoryError:PermGen异常” - deployment and “java.lang.OutOfMemoryError: PermGen exception”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM