title: Cannot load JDBC driver class 'com.mysql.jdbc.GoogleDriver'
body: <p>I am facing a very bizarre problem where my App Engine server can't load its Cloud SQL's GoogleDriver, here's the error (It happens right after I run "mvn appengine:update").</p>
  
  <pre><code>org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
          at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:596)
          ...
  Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.GoogleDriver'
          at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429)
          at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
          at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
          at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
          at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
          ... 48 more
  Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.GoogleDriver
  </code></pre>
  
  <p>appengine.properties</p>
  
  <pre><code>################### MySQL Configuration - Google Cloud App Engine ##########################
  jdbc.driverClassName=com.mysql.jdbc.GoogleDriver
  jdbc.url=jdbc:google:mysql://mytestapp:testdb?user=someuser
  jdbc.username=someuser
  jdbc.password=******
  jdbc.dialect=org.hibernate.dialect.MySQLDialect
  </code></pre>
  
  <p>In my Spring context file I have:</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:appengine.properties" /&gt;
  &lt;bean
      id="dataSource"
      class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close" &gt;
  
      &lt;property
          name="driverClassName"
          value="${jdbc.driverClassName}" /&gt;
      &lt;property
          name="url"
          value="${jdbc.url}" /&gt;
      ...
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>== </p>
  
  <p>Just to confirm, I had already configured my appengine-web.xml and it doesn't help at all:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;appengine-web-app xmlns="http://appengine.google.com/ns/1.0"&gt;
      &lt;application&gt;mytestapp&lt;/application&gt;
      &lt;version&gt;1&lt;/version&gt;
      &lt;threadsafe&gt;true&lt;/threadsafe&gt;
      &lt;sessions-enabled&gt;true&lt;/sessions-enabled&gt;
  
      &lt;system-properties&gt;
          &lt;property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/&gt;
      &lt;/system-properties&gt;
  
      &lt;use-google-connector-j&gt;true&lt;/use-google-connector-j&gt;
  &lt;/appengine-web-app&gt;
  </code></pre>
  
  <p>--</p>
  
  <p>I couldn't move forward due to some incompatibility between hibernate jar versions so I kept trying through the actual release pipeline (Jenkins + Maven + build + test + deploy), I had to add the Compute Engine VM's IP address to the list of authorized IPs of the Cloud SQL Instance in order to run my unit tests and deploy it to the application (but, if I keep this approach, I can only use the MySQL driver and URL instead of the GoogleDriver and URL. So this is getting tricky...).</p>
  
  <p>I have these properties in a Production.properties file that is loaded by my Spring MVC config file:</p>
  
  <pre><code>################### MySQL Configuration - Google Cloud App Engine ##########################
  jdbc.driverClassName=com.mysql.jdbc.GoogleDriver
  jdbc.url=jdbc:google:mysql://*******testapp:testsqldb?user=root
  jdbc.username=root
  jdbc.password=*****
  jdbc.dialect=org.hibernate.dialect.MySQLDialect
  </code></pre>
  
  <p>Is there an easy way to dynamically switch between external and GAE Cloud SQL connection details without using this approach?</p>
  
  <pre><code>if (SystemProperty.environment.value() ==
  SystemProperty.Environment.Value.Production) {
      // Connecting from App Engine.
  </code></pre>
  
  <p>Any ideas?</p>