我们使用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
- 我们使用iReport和JasperReports版本作为 4.5.1
- 我已将XercesImpl.jar(2.8.1 版)依赖项放在类路径中
- 我们正在使用Jdk.1.6.0_33
请帮助我如何消除这个错误?