title: Groovy Class loader wont load Java class
body: <p>I have this groovy script written in .groovy file:</p>
  
  <pre><code>import groovy.sql.Sql;
  def doit() {
      Class.forName('oracle.jdbc.driver.OracleDriver'); // If i skip this line it throws SQLException no driver registered for URL
      def db = [url:'jdbc:oracle:thin:/@localhost:1555:AVDB', user:'sys as sysdba', password:'secret',driver:'oracle.jdbc.driver.OracleDriver'];
      def sql = Sql.newInstance(db.url, db.user, db.password, db.driver) ;
      sql.execute 'CREATE USER RandomUser identified by Secret123';
  }
  </code></pre>
  
  <p>I am calling above Groovy from Java in following way:</p>
  
  <pre><code>ClassLoader parent = getClass().getClassLoader();
  GroovyClassLoader loader = new GroovyClassLoader(parent);
  
  Class groovyClass = loader.parseClass(groovySource); // groovySource is a File object pointing to .groovy file
  GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance();
  Object[] args = {};
  groovyObject.invokeMethod("doit", args);
  </code></pre>
  
  <p><strong>Problem</strong>:</p>
  
  <p>Class <strong>oracle.jdbc.driver.OracleDriver</strong> is present in Java's classpath but groovy cant find it at line: <code>Class.forName('oracle.jdbc.driver.OracleDriver');</code></p>
  
  <p>Throws ClassNotFoundException.</p>