Running Report with third level subreport from java generated Nullpointer

0

Hi, currently I'm trying to run my report from existing java code which I need to check for usability with subreports of differing depth.

The current report has multiple subreports from which one has a subreport that has another subreport, so we are talking about third level depths here.

The error message says something about return values gone wrong, which I don't quite get as the deepest subreport may be having return values that could go wrong in theory, but I the report it returns it's values to returns them to his parent report as well and that one works just fine. The structure of the document is as follows.

  1. Main Report with multiple subreports which don't get called every time but depending on several conditions. So for the print I'm trying to test only three specific subreports (two different headers and the data subreport) are getting called.
  2. Headers: Work just fine, do what they are supposed to do, but their SQL statements are quite simple and they don't return anything at all.
  3. Monthly subreport which has two different tables with captions that need to be above one another but in different bands, then has a weekly subreport, a table (same format as the above mentioned) for summing up the values returned by the weekly subreport and a summarizing subreport (which also works just fine because it doesn't get many parameters, doesn't return anything and has quite a simple SQL)
  4. Weekly subreport which has a daily subreport and a table (same format as the previous tables) for summing up the values returned by the daily subreport.
  5. Daily subreport which has two tables, both in the well known format. One is for the actual data of that specific day, the other is for summing up the returned values from the data table. The data from this report should get returned to weekly report, summed up there and returned to monthly report and summed up there.

So as you can see it's not the simplest of all documents. What I don't get is that even with initial value expressions of the variables in all reports the error exists in the deepest level. Weekly report and monthly report work just fine if I delete the daily one, so I know the problem is in there. Should not be the summing up either as the other two reports do it the same and it works just fine.

I don't quite think the amount of information I just gave will be enough for you to help me out here, so if anyone needs additional bits of information I haven't thought of, do tell me please.

The error I get when trying to run the report is as follows:

 

07:54:38,317 WARN  [org.hornetq.jms.client] (Thread-11 (HornetQ-client-global-threads-740737563)) HQ122001: Unhandled exception thrown from onMessage: java.lang.NullPointerException
        at net.sf.jasperreports.engine.fill.FillReturnValues.addReturnValue(FillReturnValues.java:121) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.FillReturnValues.<init>(FillReturnValues.java:92) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillDatasetRun.initReturnValues(JRFillDatasetRun.java:130) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillDatasetRun.<init>(JRFillDatasetRun.java:92) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getDatasetRun(JRFillObjectFactory.java:1437) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.components.table.fill.FillTable.<init>(FillTable.java:98) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.components.table.FillTableFactory.toFillComponent(FillTableFactory.java:51) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillComponentElement.<init>(JRFillComponentElement.java:72) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillObjectFactory.visitComponentElement(JRFillObjectFactory.java:1685) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.base.JRBaseComponentElement.visit(JRBaseComponentElement.java:81) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.JRAbstractObjectFactory.getVisitResult(JRAbstractObjectFactory.java:88) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillElementGroup.<init>(JRFillElementGroup.java:82) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillElementContainer.<init>(JRFillElementContainer.java:89) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillBand.<init>(JRFillBand.java:91) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(JRFillObjectFactory.java:521) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillSection.<init>(JRFillSection.java:74) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getSection(JRFillObjectFactory.java:497) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:282) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:72) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillSubreport.initSubreportFiller(JRFillSubreport.java:550) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:468) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:345) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:454) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2029) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:755) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:262) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:122) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:551) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:393) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:728) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:58) [jasperreports-6.0.4.jar:6.0.4]
        at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:216) [jasperreports-6.0.4.jar:6.0.4]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_72]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_72]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_72]

MiditecReportDev's picture
Joined: Mar 6 2016 - 11:42pm
Last seen: 1 year 1 month ago

4 Answers:

0

Are you passing parameters to sub-sub-report from parameter in the main report? All parameters must be present in the main report. 

hozawa's picture
52632
Joined: Apr 24 2010 - 4:31pm
Last seen: 5 months 1 week ago
0

Yes, I do pass parameters all the way down, but those parameters are present in the main report, I made sure of that.

It is one table that seems to be the problem which has something to do with ReturnValues which seems kind of strange to me as in the Studio everything works fine, but running from java is produces the mentioned NullPointer.

MiditecReportDev's picture
Joined: Mar 6 2016 - 11:42pm
Last seen: 1 year 1 month ago
0

Ok - found the problem(s) but still can't solve them.

Daily Subreport has a table for the values inside itself, which returns them to the subreport itself who in turn passes them as parameters to another table and returns them to Weekly Subreport who passes them as parameters to a table and returns them to Monthly Subreport where they get passed in a table.

 

There is no problem when it comes to returning even totally empty values from Daily to Weekly or Weekly to Monthly Reports, works fine. But when I even try returning something from the value table of Daily Subreport to Daily Subreport itself it crashes immediately.

Works fine from the studio, doesn't work if started using Java. Everything else is totally identical, I even removed initial values of the variables in the table to make everything exactly as it is one level higher (where it works) - still nothing. Crashes with NullPointer.

 

Also a second problem is, that I cant use phrases like "new java.text.SimpleDateFormat("EE. dd.MM.yyyy",new Locale($P{Locale},UPPER($P{Locale}))).format($P{DATE})" because it's crashing as well. This too does work perfectly fine if compiled directly from the studio and filled there. But filling it with Java will crash it.

MiditecReportDev's picture
Joined: Mar 6 2016 - 11:42pm
Last seen: 1 year 1 month ago
0

Ok, solved it myself now.

It was the versions. Seems we were running with 6.0.4 of Jasper Reports and after updating to 6.2.0 it works just fine without further changes.

MiditecReportDev's picture
Joined: Mar 6 2016 - 11:42pm
Last seen: 1 year 1 month ago
Feedback