I am new to jasper and in the exploration phase to replace it with the existing reporting engine. The report works fine for smaller data set, but I am facing this issue while generating a report for a large dataset (around 50k records). While filling report, the below error is encountered -
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]
then it continues to export the report, and the final report generated is incomplete.
I have also tried using JRSwapFileVirtualizer as below, but I am still getting the same error -
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());
Am I not using the virtualizer correctly? If the problem is not with virtualizer usage, then can someone please help me with the root cause and possible solution to this problem? Any help is greatly appreciated. Thanks in advance.
I got the problem, do not know the reason why it was happening though. Basically, I had 2 problems -
As posted in the question, I am using JREmptyDataSource in the fillReport call. The connection reset error disappeared after I changed the code to
JasperPrint jPrint = JasperFillManager.fillReport(jreport, paramMap);
Also, there was no other impact after removing this.
For the second problem, I was generating an html report and whenever I opened it in UI, it rendered incomplete. So I tried downloading the report to my local system and then opening it in the browser, which worked fine. This means, the report was not getting generated incomplete but was getting rendered incomplete, probably due to high data.
Posting this just in case anyone else faces a similar issue.