title: Pass connection from Java Application to Birt report
body: <p>I'm new to Birt. </p>
  
  <p>I'm trying to pass the connection to the report from my java application, but I get an error:</p>
  
  <blockquote>
    <p>The following items have errors:</p>
    
    <p>ReportDesign (id = 1):
    + There are errors evaluating script "importPackage(Packages.it.lfiammetta.birt); var conn = new
    ReportRenderer(); 
    reportContext.getAppContext().put("OdaJDBCDriverPassInConnection",
    conn);": Fail to execute script in function __bm_beforeOpen(). Source:</p>
    
    <p>" + importPackage(Packages.it.lfiammetta.birt); var conn = new
    ReportRenderer(); 
    reportContext.getAppContext().put("OdaJDBCDriverPassInConnection",
    conn); + "</p>
    
    <p>A BIRT exception occurred. See next exception for more information.
    Error evaluating Javascript expression. Script engine error:
    ReferenceError: "ReportRenderer" is not defined.
    (/report/data-sources/oda-data-source[@id="43"]/method[@name="beforeOpen"]#2)
    Script source:
    /report/data-sources/oda-data-source[@id="43"]/method[@name="beforeOpen"],
    line: 0, text:
    __bm_beforeOpen(). (Element ID:1)</p>
  </blockquote>
  
  <p>This is my java code that creates and launches report:</p>
  
  <pre><code>package it.lfiammetta.birt;
  
  public class ReportRenderer {
          public void executeReport() {
                  code...
  
                  Map&lt;String, Object&gt; appContext = task.getAppContext();
                  appContext.put("OdaJDBCDriverPassInConnection", myConnection);
                  appContext.put("OdaJDBCDriverPassInConnectionCloseAfterUse", false);
                  task.setAppContext(appContext);
  
                  task.run();
  
                  code...
          }
  }
  </code></pre>
  
  <p>This is the code I wrote in the script 'beforeOpen' the datasource:</p>
  
  <pre><code>importPackage(Packages.it.lfiammetta.birt);
  
  var conn = new ReportRenderer(); 
  reportContext.getAppContext().put("OdaJDBCDriverPassInConnection", conn);
  </code></pre>
  
  <p>I set the classpath.</p>
  
  <p>Birt version I'm using is 4.2.1.</p>
  
  <p>Thanks in advance for your help and I apologize for my English. </p>