简体   繁体   English

Java碧玉报告NullPointerException

[英]Java jasper report NullPointerException

I am new to Java and I am running into this issue that I can't figure out. 我是Java的新手,我遇到了无法解决的问题。 I inherited this project and I have the following code in one of my scriptlets: 我继承了这个项目,并且在我的一个脚本中包含以下代码:

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

And I am getting the following results (the fourth line there is line 287 in FootwearReportsServlet.doGet): 我得到以下结果(第四行在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)

What I can't figure out is where the null reference is. 我不知道是空引用在哪里。 From the debug lines I can see that each parameter has a value. 从调试行中,我可以看到每个参数都有一个值。 Could it be referring to a bad path to one of the images? 难道是指指向其中一张图片的错误路径? Any ideas? 有任何想法吗? For some reason my server won't start in debug mode in Eclipse so I am having trouble figuring this out. 由于某种原因,我的服务器无法在Eclipse中以调试模式启动,因此我很难弄清楚这一点。

From looking at the line where you are getting the error: 通过查看出现错误的行:

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

In the JRFiller source code it corresponds to 在JRFiller源代码中,它对应于

jasperPrint = filler.fill(parameters, dataSource);

The only thing that can cause a NullPointerException in this line is the case when filler is null . 在此行中唯一会导致NullPointerException的情况是fillernull的情况。 The parameters are not checked for null at this point. 此时不检查参数是否为null

Looking at the code of createFiller (line 134), you can easily see the condition in which that function returns a null pointer. 查看createFiller的代码(第134行),您可以轻松地看到该函数返回空指针的情况。 So I guess you somehow forgot to specify the print order ( PRINT_ORDER_HORIZONTAL or PRINT_ORDER_VERTICAL ). 因此,我想您以某种方式忘记了指定打印顺序( PRINT_ORDER_HORIZONTALPRINT_ORDER_VERTICAL )。

I have got the same problem. 我有同样的问题。

Roland Illig is right, the print order is missing. Roland Illig是正确的,缺少打印命令。 This might be because the compiled report file is missing required fields. 这可能是因为编译后的报告文件缺少必填字段。

Adding a value to the print order field afterwards does not help, it just keeps crashing at the next position where another field is missing. 之后在打印顺序字段中添加一个值无济于事,它只会在其他字段丢失的下一个位置继续崩溃。

Use the same version of the compiler (for example iReport) and your runtime library. 使用相同版本的编译器(例如iReport)和运行时库。

Remove order from all your series and categories. 从所有系列和类别中删除订单。 It will remove this exception. 它将删除此异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM