title: Getting Error retrieving field value from bean Exception with JasperReports API
body: <p>I am trying to get a sample report generated by <em>JasperReports</em> but it is throwing some exception that I can not understand. </p>
  
  <p>I have a bean:</p>
  
  <pre><code>class DataBean {
  
      public String country;
      public String name;
  
      public String getCountry() {
          return country;
      }
  
      public void setCountry(String country) {
          this.country = country;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>A class that results list of above bean:</p>
  
  <pre><code>class DataBeanList {
      public ArrayList&lt;DataBean&gt; getDataBeanList() {
          ArrayList&lt;DataBean&gt; dataBeanList = new ArrayList&lt;DataBean&gt;();
          dataBeanList.add(produce("Manisha", "India"));
          dataBeanList.add(produce("Dennis Ritchie", "USA"));
          dataBeanList.add(produce("V.Anand", "India"));
          dataBeanList.add(produce("Shrinath", "California"));
          return dataBeanList;
      }
  
      private DataBean produce(String name, String country) {
          DataBean dataBean = new DataBean();
          dataBean.setName(name);
          dataBean.setCountry(country);
          return dataBean;
      }
  }
  </code></pre>
  
  <p>This is how i am doing:</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
      String sourceFileName = "/home/oodles/Samples/jasper_report_template.jasper";
      DataBeanList DataBeanList = new DataBeanList();
      ArrayList&lt;DataBean&gt; dataList = DataBeanList.getDataBeanList();
      System.out.println("&lt;&lt;&lt;" + dataList.get(0).getCountry());
      JasperReportBuilder report = DynamicReports.report();
      JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dataList, false);
      report.setDataSource(beanColDataSource);
      Map parameters = new HashMap();
      try {
          JasperFillManager.fillReportToFile(sourceFileName, parameters,
                  beanColDataSource);
      } catch (JRException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>The Exception is the following:</p>
  
  <pre><code>    net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : country
      at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:123)
      at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldValue(JRAbstractBeanDataSource.java:96)
      at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:100)
      at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:1331)
      at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1232)
      at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1208)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1554)
      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:149)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:841)
      at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:88)
      at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:653)
      at net.sf.jasperreports.engine.JasperFillManager.fillToFile(JasperFillManager.java:542)
      at net.sf.jasperreports.engine.JasperFillManager.fillToFile(JasperFillManager.java:494)
      at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:874)
      at com.general.ReportsMain.main(ReportsMain.java:80)
  Caused by: java.lang.NoSuchMethodException: Property 'country' has no getter method in class 'class com.general.DataBean'
      at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1318)
      at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:762)
      at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:837)
      at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426)
      at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:111)
      ... 15 more
  </code></pre>
  
  <p>In case you need to see .jasper file source:
  <br> i am attaching only fields to show only meaningful code here:</p>
  
  <pre><code>&lt;field name="country" class="java.lang.String"&gt;
      &lt;fieldDescription&gt;&lt;![CDATA[country]]&gt;&lt;/fieldDescription&gt;
  &lt;/field&gt;
  &lt;field name="name" class="java.lang.String"&gt;
      &lt;fieldDescription&gt;&lt;![CDATA[name]]&gt;&lt;/fieldDescription&gt;
  &lt;/field&gt;
  </code></pre>