gpt4 book ai didi

Java jasper 报 NullPointerException

转载 作者:行者123 更新时间:2023-11-29 07:22:08 26 4
gpt4 key购买 nike

我是 Java 新手,我遇到了这个我无法解决的问题。我继承了这个项目,并且我的 scriptlet 之一中有以下代码:

DefaultLogger.logMessage("DEBUG path: "+ reportFile.getPath());
DefaultLogger.logMessage("DEBUG parameters: "+ parameters);
DefaultLogger.logMessage("DEBUG jr: "+ jr);
bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, jr);

我得到以下结果(第四行是 FootwearReportsServlet.doGet 中的第 287 行):

DEBUG path: C:\Development\JavaWorkspaces\Workspace1\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\RSLDevelopmentStandard\reports\templates\footwear\RslFootwearReport.jasper
DEBUG parameters: {class_list_subreport=net.sf.jasperreports.engine.JasperReport@b07af1, signature_path=images/logo_reports.jpg, submission_id=20070213154168780, test_results_subreport=net.sf.jasperreports.engine.JasperReport@5795ce, logo_path=images/logos_3.gif, report_connection_secondary=com.mysql.jdbc.JDBC4Connection@2c39d2, testing_packages_subreport=net.sf.jasperreports.engine.JasperReport@1883d5f, signature_path2=images/logo_reports.jpg, tpid_subreport=net.sf.jasperreports.engine.JasperReport@17531fd, first_page_subreport=net.sf.jasperreports.engine.JasperReport@12504e0}
DEBUG jr: net.sf.jasperreports.engine.data.JRMapCollectionDataSource@1630eb6
Apr 29, 2010 4:15:13 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet FootwearReportsServlet threw exception
java.lang.NullPointerException
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:517)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdf(JasperRunManager.java:385)
at com.rsl.reports.FootwearReportsServlet.doGet(FootwearReportsServlet.java:287)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)

我不知道空引用在哪里。从调试行中我可以看到每个参数都有一个值。它是否指的是通往其中一张图像的错误路径?有任何想法吗?由于某种原因,我的服务器无法在 Eclipse 中以 Debug模式启动,因此我无法解决这个问题。

最佳答案

查看出现错误的行:

jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)

在JRFiller源代码中它对应

jasperPrint = filler.fill(parameters, dataSource);

此行中唯一可能导致 NullPointerException 的情况是 fillernull 的情况。此时不会检查参数是否为 null

查看createFiller的代码(第134行),您可以轻松地看到该函数返回空指针的情况。所以我猜您忘记指定打印顺序(PRINT_ORDER_HORIZONTALPRINT_ORDER_VERTICAL)。

关于Java jasper 报 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2741394/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com