Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Null 'key' argument error

I'm using IReport 3.5.0 and my java GWT application uses the compiled .jasper file, to create a report. I'm creating the datasource in the java application and use fillReport() method to fill the report. It works fine, it fills the fields that I have defined both in the .jrxml and Java application.

However, I want to use those fields to create a pie chart, and it doesn't work. I give my working fields as key and value expressions for the chart, but when I run the application, it gives the error java.lang.IllegalArgumentException: Null 'key' argument. I couldn't solve it, even when I give $V{PAGE_COUNT} as key expression, it always give the same 'null key' error. I'm stuck. Thanks for any help.

like image 278
Halo Avatar asked Aug 10 '10 08:08

Halo


2 Answers

I had the same kind of issue. Basically the Pie Chart in JasperReport hates null object. The error message doesn't help very much...

Since you have already check for the key expression, check every other elements. My error was in a label expression!

If you can run your application in a IDE, put a breakpoint on "IllegalArgumentException". It will help you find the root cause. Also make sure the report recompile the jrxml every time you make a change.

Another approach would be to start with an example and modify it to fit your need little by little. You will find the culprit soon enough!

By the way, this has nothing to do with GWT since this all run on the server.

like image 159
Thierry-Dimitri Roy Avatar answered Oct 16 '22 10:10

Thierry-Dimitri Roy


I had the same kind of problem with iReport 3.0 I used conditionals to work with null values on key expression and value expression:

($F{FIELDEXPRESSION}!=null?$F{FIELDEXPRESSION}:"")

($F{FIELDVALUE}!=null?(new BigDecimal($F{FIELDVALUE})):(new BigDecimal("0")))
like image 3
jlago Avatar answered Oct 16 '22 10:10

jlago