title: ClassNotFoundException with Spring Boot and ibm JDBC driver
body: <p>I'm trying to set up a spring-boot application to connect to a DB2 database on an IBM i machine.  I've added a maven dependency to an IBM jdbc driver <code>com.ibm.as400.access.AS400JDBCDriver</code> and added <code>spring.datasource.driver-class-name="com.ibm.as400.access.AS400JDBCDriver"</code> to the application.properties file.  </p>
  
  <p>When I run the application, I get an error <code>Cannot load driver class: "com.ibm.as400.access.AS400JDBCDriver</code>.  The error happens at the <code>ClassUtils.forName</code> line below in the DataSourceProperties class from spring-boot in org.springframework.boot.autoconfigure.jdbc</p>
  
  <pre><code>private boolean driverClassIsLoadable() {
      try {
          ClassUtils.forName(this.driverClassName, null); &lt;----- Exception happens here.  
          return true;
      }
      catch (UnsupportedClassVersionError ex) {
          // Driver library has been compiled with a later JDK, propagate error
          throw ex;
      }
      catch (Throwable ex) {
          return false;
      }
  }
  </code></pre>
  
  <p>this.driverClassName equals "com.ibm.as400.access.AS400JDBCDriver".  Interestingly, in my main method, I can call the same function with the same driverClassName and get no exception.</p>
  
  <pre><code>@SpringBootApplication
  public class MinimumExampleApplication {
  
  public static void main(String[] args) throws ClassNotFoundException, LinkageError {
      ClassUtils.forName("com.ibm.as400.access.AS400JDBCDriver", null); &lt;---- No exception here?
      SpringApplication.run(MinimumExampleApplication.class, args);
    }
  }
  </code></pre>
  
  <p>My question is why is spring-boot unable to find the driver when I can find the driver if I load it myself?</p>
  
  <p>Full Program</p>
  
  <p><code>MinimumExample.java</code></p>
  
  <pre><code>package org.mystuff.annual.meeting.signup;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.util.ClassUtils;
  
  @SpringBootApplication
  public class MinimumExampleApplication {
  
    public static void main(String[] args) throws ClassNotFoundException,    LinkageError {
      ClassUtils.forName("com.ibm.as400.access.AS400JDBCDriver", null);
      SpringApplication.run(MinimumExampleApplication.class, args);
    }
  }
  </code></pre>
  
  <p><code>application.properties</code></p>
  
  <pre><code>spring.datasource.driver-class-name="com.ibm.as400.access.AS400JDBCDriver"
  spring.datasource.url="jdbc:db2://myserver/myDb"
  spring.datasource.dbcp2.initial-size=2
  spring.datasource.dbcp2.max-total=5
  </code></pre>
  
  <p><code>pom.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;org.mystuff&lt;/groupId&gt;
      &lt;artifactId&gt;annual-meeting-signup&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;minimum-example&lt;/name&gt;
      &lt;description&gt;Playing with data repository&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.mystuff&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.5.2.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.ibm.as400&lt;/groupId&gt;
              &lt;artifactId&gt;jt400&lt;/artifactId&gt;
              &lt;version&gt;8&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  
  &lt;/project&gt;
  </code></pre>