title: org.flywaydb.core.api.FlywayException: Unable to instantiate JDBC driver when my java class is triggered from ant taskdef
body: <p>I have written a java class which uses the dependency jar flyway-core-4.0.3.jar loaded from the taskdef action classpath and invoking the methods in the flyway jar, the following is the part of the code which is causing the issue </p>
  
  <pre><code>   public static boolean executeFlywayMigrate(String connectionUrl, String username, String password,
          String scriptLocation, String[] databaseNames, Map&lt;String, String&gt; componentProperties,
          boolean validateOnMigrate)
          throws SQLException {
      LOGGER.info("Database schemas for migration are :" + Arrays.toString(databaseNames));
      try {
          Flyway flyway = new Flyway();
          flyway.setLocations(scriptLocation);
          flyway.setSchemas(databaseNames);
          flyway.setBaselineOnMigrate(true);
          flyway.setDataSource(connectionUrl, username, password);
          if (componentProperties != null) {
              flyway.setPlaceholders(componentProperties);
          }
          flyway.setValidateOnMigrate(validateOnMigrate);
          flyway.repair();
          flyway.migrate();
      } catch (RuntimeException e) {
          LOGGER.error("Database migration failed.", e);
          throw new SQLException(e);
      }
  </code></pre>
  
  <p>I am triggering the class with ant using taskdef action. I have given the classpathref for the taskdef action.</p>
  
  <pre><code>&lt;taskdef name="ExecuteMigrationScripts" classname="com.install.common.db.action.ExecuteMigrationScripts" 
                  classpathref="class.dependencies" loaderref="class.dependencies.loader"/&gt;
  &lt;ExecuteMigrationScripts/&gt; 
  </code></pre>
  
  <p>The issue occurs only when flyway tries to seach for the db jar (in my case i have tried with both mysql-connector-java-5.1.39-bin.jar and sqljdbc41.jar but the same issue arises). </p>
  
  <p>NOTE: If i trigger a different class from taskdef action which tries to connect to the database and create a sample database schema, that works fine and that could able to load the same db jars from the classpath mentioned in the taskdef action but the issue occurs only when flyway is trying to locate the db jar.</p>
  
  <p>Please help me if i am missing something here.</p>