Jasper 报告 - 填写报告时连接重置

Jasper report - connection reset while filling report

我是 jasper 的新手,正处于用现有报告引擎替换它的探索阶段。 该报告适用于较小的数据集,但我在为大型数据集(大约 50k 条记录)生成报告时遇到了这个问题。填写报告时,遇到以下错误 -

2021-06-24 17:20:26,039+05:30 WARN net.sf.jasperreports.data.DataFileUtils [pool-7-thread-1] - Failed to dispose stream for net.sf.jasperreports.data.http.HttpDataConnection@3cddfb2
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[?:1.8.0_252]
        at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[?:1.8.0_252]
        at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) ~[?:1.8.0_252]
        at sun.security.ssl.InputRecord.readV3Record(InputRecord.java:593) ~[?:1.8.0_252]
        at sun.security.ssl.InputRecord.read(InputRecord.java:532) ~[?:1.8.0_252]
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:990) ~[?:1.8.0_252]
        at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:948) ~[?:1.8.0_252]
        at sun.security.ssl.AppInputStream.read(AppInputStream.java:105) ~[?:1.8.0_252]
        at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) ~[httpcore-4.4.13.jar:4.4.13]
        at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) ~[httpcore-4.4.13.jar:4.4.13]
        at org.apache.http.impl.io.SessionInputBufferImpl.read(SessionInputBufferImpl.java:205) ~[httpcore-4.4.13.jar:4.4.13]
        at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:188) ~[httpcore-4.4.13.jar:4.4.13]
        at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:210) ~[httpcore-4.4.13.jar:4.4.13]
        at org.apache.http.impl.io.ChunkedInputStream.close(ChunkedInputStream.java:312) ~[httpcore-4.4.13.jar:4.4.13]
        at org.apache.http.impl.execchain.ResponseEntityProxy.streamClosed(ResponseEntityProxy.java:142) ~[httpclient-4.5.13.jar:4.5.13]
        at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:228) ~[httpclient-4.5.13.jar:4.5.13]
        at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:172) ~[httpclient-4.5.13.jar:4.5.13]
        at org.apache.http.client.entity.LazyDecompressingInputStream.close(LazyDecompressingInputStream.java:97) ~[httpclient-4.5.13.jar:4.5.13]
        at java.io.FilterInputStream.close(FilterInputStream.java:181) ~[?:1.8.0_252]
        at net.sf.jasperreports.data.DataFileStream.dispose(DataFileStream.java:87) [jasperreports-6.17.0.jar:6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd]
        at net.sf.jasperreports.data.json.JsonDataAdapterService.dispose(JsonDataAdapterService.java:142) [jasperreports-6.17.0.jar:6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd]
        at net.sf.jasperreports.engine.fill.JRFillDataset.disposeParameterContributors(JRFillDataset.java:1196) [jasperreports-6.17.0.jar:6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd]
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:649) [jasperreports-6.17.0.jar:6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd]
        at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) [jasperreports-6.17.0.jar:6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd]
        at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) [jasperreports-6.17.0.jar:6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd]
        at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) [jasperreports-6.17.0.jar:6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd]
        at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) [jasperreports-6.17.0.jar:6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd]
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1074) [jasperreports-6.17.0.jar:6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd]

然后继续导出报表,最终生成的报表不完整

我也试过如下使用 JRSwapFileVirtualizer,但我仍然遇到同样的错误 -

JRSwapFile swapFile = new JRSwapFile(getReportOutputDir(sReport.getId()).toString(), 100, 10); // also tried with arguments 1024, 1024
JRSwapFileVirtualizer virtualizer = new JRSwapFileVirtualizer(20, swapFile);
Map<String, Object> paramMap = new HashMap();
paramMap.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
                
JasperPrint jPrint = JasperFillManager.fillReport(jreport, paramMap, new JREmptyDataSource());

我是不是没有正确使用虚拟器? 如果问题不在于虚拟器的使用,那么有人可以帮我解决这个问题的根本原因和可能的解决方案吗? 任何帮助是极大的赞赏。提前致谢。

我遇到了问题,但不知道它发生的原因。 基本上,我有 2 个问题 -

  1. 日志中的连接重置错误
  2. 正在生成不完整的报告(html)

如问题中所述,我在 fillReport 调用中使用了 JREmptyDataSource。将代码更改为

后,连接重置错误消失了
JasperPrint jPrint = JasperFillManager.fillReport(jreport, paramMap);

此外,去掉这个后没有其他影响。

对于第二个问题,我正在生成一份 html 报告,但每当我在 UI 中打开它时,它都会显示不完整。所以我尝试将报告下载到我的本地系统,然后在浏览器中打开它,效果很好。这意味着,报告不是生成不完整而是呈现不完整,可能是由于数据量大。

张贴这个以防其他人遇到类似问题。