views:

155

answers:

1

I am new to Java and I am running into this issue that I can't figure out. 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):

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.

+1  A: 

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

jasperPrint = filler.fill(parameters, dataSource);

The only thing that can cause a NullPointerException in this line is the case when filler is null. The parameters are not checked for null at this point.

Looking at the code of createFiller (line 134), you can easily see the condition in which that function returns a null pointer. So I guess you somehow forgot to specify the print order (PRINT_ORDER_HORIZONTAL or PRINT_ORDER_VERTICAL).

Roland Illig