JasperReports 在固定字符串数据输入上打破了 IndexOutOfBoundsException(Java/Gradle 内置)
JasperReports Breaking with IndexOutOfBoundsException on Fixed String Data input (Java/Gradle Built)
我在 Java Spring 应用程序中生成 Jasper Reports PDF 时遇到问题。
版本:
- Java 8
- Spring 4.3.3
- 图书馆:
- olap4j 1.2.0
- 碧玉报告 6.11.0
- itextpdf 5.5.13.1
使用 jasperreports-gradle-plugin 版本 0.3.2
构建的 Jasper 文件
<!-- Created with Jaspersoft Studio version 6.11.0.final using JasperReports Library version 6.11.0-0c4056ccaa4d25a5a8c45672d2f764ea3498bebb -->
...
<textField>
<reportElement positionType="Float" x="2" y="161" width="582" height="9" uuid="c39550b8-8786-424e-ae97-54db0f570a05"/>
<box padding="3">
<pen lineWidth="0.5" lineStyle="Solid"/>
</box>
<textElement verticalAlignment="Middle">
<font fontName="Liberation Sans" size="6" isItalic="true" pdfFontName="Helvetica-Oblique" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{String_Input}]]></textFieldExpression>
</textField>
...
当我从我的 jrxml 文件中注释掉上面的代码片段时,它适用于我设置的所有示例。但是,当我将其添加回去时,它适用于除一个以外的所有对象,在这种情况下,它会提供以下堆栈跟踪:
SEVERE: Servlet.service() for servlet [orderInvoice] in context with path [/orderInvoice] threw exception [Request processing failed; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0] with root cause
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at com.lowagie.text.pdf.PdfStructureTreeRoot.nodeProcess(Unknown Source)
at com.lowagie.text.pdf.PdfStructureTreeRoot.nodeProcess(Unknown Source)
at com.lowagie.text.pdf.PdfStructureTreeRoot.nodeProcess(Unknown Source)
at com.lowagie.text.pdf.PdfStructureTreeRoot.buildTree(Unknown Source)
at com.lowagie.text.pdf.PdfWriter.getCatalog(Unknown Source)
at com.lowagie.text.pdf.PdfWriter.close(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)
at com.lowagie.text.Document.close(Unknown Source)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:941)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:547)
[exporter.exportReport();]
[buildInvoicePDF(response, result);]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
这没有意义,因为有时应该发生,而不是一直发生。传入的字符串被硬编码在代码中,作为管理任何更新的一种方式,但这感觉更像是一个配置问题而不是一个 jrxml 问题,因为这段代码已经稳定了一年多,并且没有出现问题在正常的变化中。我已经统一了用于构建 jrxml 的 JasperReport 库。我检查了每个版本以试图找出问题所在,并且可以使用修复程序或关于如何找到修复程序的想法。我在 google 上没有发现任何内容或任何明显的问题。
谢谢
所以这是我对相关应用程序进行清理后的产物。
原始设计包括一些标记以使 PDF ADA 兼容,因为它使用旧版本的 Jasper Reports。我删除了它以解决一些稳定性问题,但有一组新的稳定性问题(参见问题)。
问题出在这段代码上:
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
configuration.setTagged(true);
需要这个 true
来支持这些添加的标签,但是删除它们会造成麻烦,因此变成:
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
configuration.setTagged(false);
我在 Java Spring 应用程序中生成 Jasper Reports PDF 时遇到问题。
版本:
- Java 8
- Spring 4.3.3
- 图书馆:
- olap4j 1.2.0
- 碧玉报告 6.11.0
- itextpdf 5.5.13.1
使用 jasperreports-gradle-plugin 版本 0.3.2
构建的 Jasper 文件<!-- Created with Jaspersoft Studio version 6.11.0.final using JasperReports Library version 6.11.0-0c4056ccaa4d25a5a8c45672d2f764ea3498bebb -->
...
<textField>
<reportElement positionType="Float" x="2" y="161" width="582" height="9" uuid="c39550b8-8786-424e-ae97-54db0f570a05"/>
<box padding="3">
<pen lineWidth="0.5" lineStyle="Solid"/>
</box>
<textElement verticalAlignment="Middle">
<font fontName="Liberation Sans" size="6" isItalic="true" pdfFontName="Helvetica-Oblique" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{String_Input}]]></textFieldExpression>
</textField>
...
当我从我的 jrxml 文件中注释掉上面的代码片段时,它适用于我设置的所有示例。但是,当我将其添加回去时,它适用于除一个以外的所有对象,在这种情况下,它会提供以下堆栈跟踪:
SEVERE: Servlet.service() for servlet [orderInvoice] in context with path [/orderInvoice] threw exception [Request processing failed; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0] with root cause
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at com.lowagie.text.pdf.PdfStructureTreeRoot.nodeProcess(Unknown Source)
at com.lowagie.text.pdf.PdfStructureTreeRoot.nodeProcess(Unknown Source)
at com.lowagie.text.pdf.PdfStructureTreeRoot.nodeProcess(Unknown Source)
at com.lowagie.text.pdf.PdfStructureTreeRoot.buildTree(Unknown Source)
at com.lowagie.text.pdf.PdfWriter.getCatalog(Unknown Source)
at com.lowagie.text.pdf.PdfWriter.close(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)
at com.lowagie.text.Document.close(Unknown Source)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:941)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:547)
[exporter.exportReport();]
[buildInvoicePDF(response, result);]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
这没有意义,因为有时应该发生,而不是一直发生。传入的字符串被硬编码在代码中,作为管理任何更新的一种方式,但这感觉更像是一个配置问题而不是一个 jrxml 问题,因为这段代码已经稳定了一年多,并且没有出现问题在正常的变化中。我已经统一了用于构建 jrxml 的 JasperReport 库。我检查了每个版本以试图找出问题所在,并且可以使用修复程序或关于如何找到修复程序的想法。我在 google 上没有发现任何内容或任何明显的问题。
谢谢
所以这是我对相关应用程序进行清理后的产物。
原始设计包括一些标记以使 PDF ADA 兼容,因为它使用旧版本的 Jasper Reports。我删除了它以解决一些稳定性问题,但有一组新的稳定性问题(参见问题)。
问题出在这段代码上:
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
configuration.setTagged(true);
需要这个 true
来支持这些添加的标签,但是删除它们会造成麻烦,因此变成:
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
configuration.setTagged(false);