在Windows中使用Apache Tomcat 7运行Jasper Report时出错

时间:2018-08-10 10:11:50

标签: java jasper-reports

我已经在JSP页面中配置了编译Jasper Report。我已完成连接数据库的工作,收集了JRXML文件以及报告的参数,如下所示:

JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
jasperDesign.setLanguage(language);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, jdbcConnection); //line4

在生成报告时,我在line 4中遇到错误。

我得到的是:

 exception 
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.ExceptionInInitializerError
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause 
javax.servlet.ServletException: java.lang.ExceptionInInitializerError
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:930)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:863)
    org.apache.jsp.QuaLIS.jasperReport_jsp._jspService(jasperReport_jsp.java:488)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause 
java.lang.ExceptionInInitializerError
    net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:121)
    net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:88)
    net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:103)
    net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:61)
    net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:153)
    net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:55)
    net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
    net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:849)
    org.apache.jsp.QuaLIS.jasperReport_jsp._jspService(jasperReport_jsp.java:444)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

也说

java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser

为您简要介绍一下我所做的是:

  1. 赋予启动属性 -Djava.awt.headless = true。
  2. 授予对jrxml文件以及相关的JARS的完全访问权限
  3. 检查Tomcat中是否存在临时文件夹
  4. 尝试重新启动Tomcat /服务器。
  5. 可用的JARS列表如下:
    jasper-compiler-jdt-5.5.23
    jasperreports-5.1.0
    jasperreports-chart-themes-4.5.0
    jasperreports-core-renderer
    jasperreports-extensions-3.5.3
    jasperreports-fonts-4.5.0
    jasperreports-htmlcomponent-4.1.1
    jasperreports-jtidy-r938

期待解决方案。在此先感谢!

0 个答案:

没有答案