title: Creating/Passing Java bean Datasource in JasperReport
body: <p>I am using JasperReport and ireport in my JSF application to generate reports on the fly.
  This is what I am trying to achieve:-</p>
  
  <ol>
  <li><p>My structure(read as HashMap/ArrayList) contains data that needs to be passed to the report so that the same is shown in report.</p></li>
  <li><p>My report already contains a Datasource connection using which I am fetching some value from DB and populating it in report.</p></li>
  <li><p>I am creating a subreport so that for data which needs to be passed from code I can use the subreport and embed this subreport inside the main report.</p></li>
  </ol>
  
  <p>My problem is:-
  1. I am unable to pass the collection(read as HashMap/ArrayList) to subreport to populate it with the data from my code.</p>
  
  <p>I am absolutely sure there must be some way of passing the entire collection to the subreport in order to populate it and I have also tried creating a JavaBean datasource connection however while creating a connection it says Missing classpath entry.</p>
  
  <p>I cannot bundle the respective classes inside a jar and put the jar in classpath since the values are constantly changing in the structure,....</p>
  
  <p>Can anyone please guide me on how to create/pass a java bean datasource to the report so that data can be populated...</p>
  
  <p>Kindly guide...</p>
  
  <p>Updated portion:-</p>
  
  <p>Java code for passing parameter to report and generating the report:-</p>
  
  <pre><code>public class TestDataSource
  {
      public static void main(String[] args)
      {
  
          try {
              JasperDesign jasperDesign = JRXmlLoader.load("D:\\jasperReports\\subReportDataSource.jrxml");
              JasperReport jasperReport =(JasperReport)JasperCompileManager.compileReport(jasperDesign);
              Map&lt;String,Object&gt; parameters = new HashMap&lt;String,Object&gt;();
              parameters.put ("Title",generateCollection());
  
              JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JRBeanCollectionDataSource(generateCollection()));
  
              JasperViewer.viewReport(jasperPrint);
              }catch(Exception e)
              {
                  e.printStackTrace();
              }
      }
  
      public static ArrayList&lt;PersonBean&gt; generateCollection()
      {
          ArrayList&lt;PersonBean&gt; arrlist=new ArrayList&lt;PersonBean&gt;();
          arrlist.add(new PersonBean("A", 20));
          arrlist.add(new PersonBean("B",30));
          arrlist.add(new PersonBean("C",40));
          arrlist.add(new PersonBean("D",50));
          arrlist.add(new PersonBean("E",40));
          arrlist.add(new PersonBean("F",60));
  
          return arrlist;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Now I created a new report (Report)..Inside that I placed a sub-report(Sub-Report)..Configured the sub-report datasource to be 
  new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{Title})</p>
  
  <p>Connection Type:-Use a datasource connection type.</p>
  
  <p>Now inside my Sub-Report I just placed two static fields as Name and Age.
  How do i Tell my report/Sub-Report to print value present as value in hashmap which is being passed.</p>