title: Getting null values when generating report using JasperReports API
body: <p>I've designed my report using <em>iReport</em> and compiled it in <em>Java</em>.</p>
  
  <p>I'm getting null values when I generate report in <em>PDF</em> format via <em>Java</em>. </p>
  
  <p>I get Key is null in pie dataset. error and the output <em>PDF</em> or <em>html</em> has <em>null</em> values.</p>
  
  <p>My code:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class PdfFromJasperFile {
  
      public static void main(String[] args) throws JRException, IOException {
  
          JasperReport jasperReport;
          JasperPrint jasperPrint;
          Map param = new HashMap();
          try {
              String sourceFileName = "C:/Users/Sadagopan/Documents/report3.jrxml";
  
              jasperReport = JasperCompileManager.compileReport(sourceFileName);
              jasperPrint = JasperFillManager.fillReport(jasperReport, param,
                      new JREmptyDataSource());
              JasperExportManager.exportReportToHtmlFile(jasperPrint, 
                      "C:/Users/Sadagopan/Documents/sample.html");
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>My <em>JRXML</em> file: </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report3" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3d69a5d5-0c1e-4b1f-9424-513fa329f402"&gt;
      &lt;queryString&gt;
          &lt;![CDATA[Select * from person where name ='sadagopan']]&gt;
      &lt;/queryString&gt;
      &lt;field name="id" class="java.lang.Long"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="name" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="address" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="phonenumber" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="salary" class="java.math.BigDecimal"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="pension" class="java.math.BigDecimal"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;group name="id"&gt;
          &lt;groupExpression&gt;&lt;![CDATA[$F{id}]]&gt;&lt;/groupExpression&gt;
      &lt;/group&gt;
      &lt;group name="name"&gt;
          &lt;groupExpression&gt;&lt;![CDATA[$F{name}]]&gt;&lt;/groupExpression&gt;
      &lt;/group&gt;
      &lt;group name="phonenumber"&gt;
          &lt;groupExpression&gt;&lt;![CDATA[$F{phonenumber}]]&gt;&lt;/groupExpression&gt;
      &lt;/group&gt;
      &lt;group name="salary"&gt;
          &lt;groupExpression&gt;&lt;![CDATA[$F{salary}]]&gt;&lt;/groupExpression&gt;
      &lt;/group&gt;
      &lt;background&gt;
          &lt;band splitType="Stretch"/&gt;
      &lt;/background&gt;
      &lt;title&gt;
          &lt;band height="60" splitType="Stretch"&gt;
              &lt;staticText&gt;
                  &lt;reportElement uuid="a006c204-9feb-4302-90b1-fe5bdddbe3d8" x="89" y="11" width="384" height="49"/&gt;
                  &lt;textElement&gt;
                      &lt;font size="36"/&gt;
                  &lt;/textElement&gt;
                  &lt;text&gt;&lt;![CDATA[Person Salary report]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
          &lt;/band&gt;
      &lt;/title&gt;
      &lt;pageHeader&gt;
          &lt;band height="27" splitType="Stretch"/&gt;
      &lt;/pageHeader&gt;
      &lt;columnHeader&gt;
          &lt;band height="25" splitType="Stretch"&gt;
              &lt;staticText&gt;
                  &lt;reportElement uuid="b74a5413-2dee-4cd5-ac06-e73a022343bc" x="0" y="5" width="48" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;text&gt;&lt;![CDATA[ID   ]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;staticText&gt;
                  &lt;reportElement uuid="9df2c923-e5b6-4bb0-95f0-5c437495ea53" x="63" y="5" width="100" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;text&gt;&lt;![CDATA[Name]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;staticText&gt;
                  &lt;reportElement uuid="b054ca79-f62e-4c80-817f-270e9ee4839a" x="163" y="5" width="176" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;text&gt;&lt;![CDATA[Address]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;staticText&gt;
                  &lt;reportElement uuid="e49b408e-8c6f-4aea-af7b-15ab31eb4643" x="329" y="5" width="100" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;text&gt;&lt;![CDATA[Phonenumber]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;staticText&gt;
                  &lt;reportElement uuid="4bf8ce1f-5284-4642-a45a-90aeff267abd" x="429" y="5" width="59" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;text&gt;&lt;![CDATA[salary]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;staticText&gt;
                  &lt;reportElement uuid="f99f4ce6-d8df-41b6-b1cb-8a5ef17b46c3" x="488" y="5" width="100" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;text&gt;&lt;![CDATA[pension]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
          &lt;/band&gt;
      &lt;/columnHeader&gt;
      &lt;detail&gt;
          &lt;band height="53" splitType="Stretch"&gt;
              &lt;textField&gt;
                  &lt;reportElement uuid="e91cc334-4623-42a2-bc78-e6c248606f65" x="0" y="0" width="48" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{id}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField&gt;
                  &lt;reportElement uuid="3b8498fb-8560-4178-86bf-183ab6855d49" x="63" y="0" width="100" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{name}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField&gt;
                  &lt;reportElement uuid="78c2be84-eebd-4465-b8c2-53d201e3246a" x="163" y="0" width="166" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{address}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField&gt;
                  &lt;reportElement uuid="813442d3-a459-4fc9-83fb-ac170bf5a9a8" x="329" y="0" width="100" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{phonenumber}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField&gt;
                  &lt;reportElement uuid="37d739d1-f413-465f-aecc-6bc2a3b8ff72" x="429" y="0" width="59" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{salary}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField&gt;
                  &lt;reportElement uuid="99c32bab-b3d5-4ade-bb47-b3858ce6e2d6" x="488" y="0" width="100" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{pension}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/detail&gt;
      &lt;columnFooter&gt;
          &lt;band height="236" splitType="Stretch"&gt;
              &lt;pieChart&gt;
                  &lt;chart&gt;
                      &lt;reportElement uuid="e214bf8f-78d8-424b-a617-4b417385a9e5" x="48" y="21" width="440" height="215"/&gt;
                      &lt;chartTitle/&gt;
                      &lt;chartSubtitle/&gt;
                      &lt;chartLegend/&gt;
                  &lt;/chart&gt;
                  &lt;pieDataset&gt;
                      &lt;keyExpression&gt;&lt;![CDATA[$F{id}]]&gt;&lt;/keyExpression&gt;
                      &lt;valueExpression&gt;&lt;![CDATA[$F{salary}]]&gt;&lt;/valueExpression&gt;
                  &lt;/pieDataset&gt;
                  &lt;piePlot&gt;
                      &lt;plot/&gt;
                      &lt;itemLabel/&gt;
                  &lt;/piePlot&gt;
              &lt;/pieChart&gt;
          &lt;/band&gt;
      &lt;/columnFooter&gt;
      &lt;pageFooter&gt;
          &lt;band height="54" splitType="Stretch"/&gt;
      &lt;/pageFooter&gt;
      &lt;summary&gt;
          &lt;band height="42" splitType="Stretch"/&gt;
      &lt;/summary&gt;
  &lt;/jasperReport&gt;
  </code></pre>