- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们使用 iReport4.5.1 创建了报告。它在 iReport 中正常工作。
之后,我们将报告集成到我们的应用程序中。我们使用 maven 构建我们的应用程序。以下是 pom.xml
中的 JasperReports 依赖项<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>jasperreports-javaflow</groupId>
<artifactId>jasperreports-javaflow</artifactId>
<version>4.5.1</version>
</dependency>
下面是生成报告的 Java 代码:
String jrxmlFilePath = getConfigBundle().getString("jasper.templates.jrxml.path");
String jasperFilePath = getConfigBundle().getString("jasper.templates.jasper.path");
JasperCompileManager.compileReportToFile(jrxmlFilePath, jasperFilePath);
File jasperFile = new File(jasperFilePath);
Connection conn = setUpDataSource();
HashMap jasperParameter = setUpJasperParameterForPackingList(truckId, rackId, jasperFile);
JasperPrint jprint = JasperFillManager.fillReport(jasperFilePath, jasperParameter, conn);
ByteArrayOutputStream reportOutputStream = new ByteArrayOutputStream();
JasperExportManager.exportReportToPdfStream(jprint, reportOutputStream);
return reportOutputStream;
当我调用这段代码时,它会给我以下错误:
ERROR - [DGU_ACTION_SERVLET] ServletException
javax.servlet.ServletException: net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at com.saintgobain.dgu.mvc.action.DguActionServlet.process(DguActionServlet.java:41)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.createParser(BaseSaxParserFactory.java:99)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1342)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1318)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:207)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:172)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:156)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:108)
at com.saintgobain.dgu.helper.ExportReportPDFHelper.printPackingListJasper(ExportReportPDFHelper.java:287)
at com.saintgobain.dgu.helper.ExportReportPDFHelper.generatePDF4PackingList(ExportReportPDFHelper.java:353)
at com.saintgobain.dgu.mvc.action.shipping.ExportShippingReportAction.execute(ExportShippingReportAction.java:79)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
... 22 more
Caused by: org.xml.sax.SAXNotRecognizedException: Property: http://java.sun.com/xml/jaxp/properties/schemaLanguage
at org.apache.crimson.parser.XMLReaderImpl.setProperty(XMLReaderImpl.java:266)
at org.apache.crimson.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:183)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.configureParser(BaseSaxParserFactory.java:132)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.createParser(BaseSaxParserFactory.java:94)
... 32 more
ERROR - [DGU_ACTION_SERVLET] ServletException - root cause
net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.createParser(BaseSaxParserFactory.java:99)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1342)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1318)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:207)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:172)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:156)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:108)
at com.saintgobain.dgu.helper.ExportReportPDFHelper.printPackingListJasper(ExportReportPDFHelper.java:287)
at com.saintgobain.dgu.helper.ExportReportPDFHelper.generatePDF4PackingList(ExportReportPDFHelper.java:353)
at com.saintgobain.dgu.mvc.action.shipping.ExportShippingReportAction.execute(ExportShippingReportAction.java:79)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at com.saintgobain.dgu.mvc.action.DguActionServlet.process(DguActionServlet.java:41)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.xml.sax.SAXNotRecognizedException: Property: http://java.sun.com/xml/jaxp/properties/schemaLanguage
at org.apache.crimson.parser.XMLReaderImpl.setProperty(XMLReaderImpl.java:266)
at org.apache.crimson.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:183)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.configureParser(BaseSaxParserFactory.java:132)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.createParser(BaseSaxParserFactory.java:94)
... 32 more
请帮助我如何消除这个错误?
最佳答案
从堆栈跟踪的这一行可以看出:
org.apache.crimson.parser.XMLReaderImpl.setProperty(XMLReaderImpl.java:266)
Crimson XML 解析器用于您的应用程序。
Crimson 实现不支持不同于这些值的属性值[1]:
"http://xml.org/sax/properties/lexical-handler"
和
"http://xml.org/sax/properties/declaration-handler"
但是 JasperReports 引擎尝试使用 http://java.sun.com/xml/jaxp/properties/schemaLanguage
属性(正如您从堆栈跟踪[2] 中看到的那样)。
iReport 正在使用 Xerces XML 解析器实现。例如,iReport 4.7.0 和 iReport 5.2.0 使用的是 2.8.0 版本的 Xerces .
您可以尝试将此 (Xerces) 库作为依赖项添加到 pom.xml。
注释:
[1]:见方法源码getProperty(String)
在 org.apache.crimson.parser.XMLReaderImpl 类中。
[2]:JR 引擎尝试在 net.sf.jasperreports.engine.xml.BaseSaxParserFactory.configureParser(SAXParser)
中为 SAXParser 设置此属性 方法。
关于java - 碧 Jade 报告 : Getting JRRuntimeException: Error creating SAX parser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17715967/
我正在使用 DynamicReports 和 JasperReports 创建一个 java 应用程序。 在尝试显示 JasperReportBuilder 时,出现此错误: ... DEBU
这个问题在这里已经有了答案: Font is not available to the JVM with Jasper Reports (20 个答案) 关闭 6 年前。 我正在使用 iReport
我正在开发一个桌面应用程序,用于使用 Java Swing 和 Jasper Reports 生成报告。几天前,我遇到了一个问题,因为我的代码无法找到 Groovy 函数。我发现this answer
我的应用程序使用 JasperReports 生成 PDF 文件。我使用 Assembly Maven 插件为我的应用程序生成一个 jar。 问题是,当我使用命令行 java -cp "PrintOu
我们使用 iReport4.5.1 创建了报告。它在 iReport 中正常工作。 之后,我们将报告集成到我们的应用程序中。我们使用 maven 构建我们的应用程序。以下是 pom.xml 中的 Ja
我正在尝试通过 JasperReport 创建 PDF 报告,但读取字体数据时出现问题。我在 ClassPath 中有 jasperreports_extension.properties 和相关的
我有 Jasper 报告,我想将其显示为 xls 报告。 之前我遇到了用于 xls 编写的 poi 库的问题,通过添加带有 commons-collections4-4 的 poi 3.15 库解决了
我创建了一个 Java 程序,它使用 JasperReports 创建报告。在我的 JasperReports 之一中,我使用 theme="eye.candy.sixties"。 当我在 gui 中
我是一名优秀的程序员,十分优秀!