title: Tomcat Unable to create initial connections of pool
body: <p>So I have a web app which I deploy / redeploy on a remote Tomcat server instance. Sometimes, the deploy and even redeploy (by redeploy I mean moving the ROOT.war through SFTP and leave Tomcat to actually redeploy it) work as expected, no issues whatsoever with the database connection. Unfortunately, other times, after redeploy, it just refuses to connect to the database, as apparently it doesn't recognize the MySQL driver anymore. The MySQL connector lib is inside Tomcat's lib folder, not package with the WAR.</p>
  
  <p><strong>pom.xml:</strong></p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;5.1.36&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>webapp/WEB-INF/web.xml:</strong></p>
  
  <pre><code>&lt;resource-ref&gt;
      &lt;description&gt;App MySQL&lt;/description&gt;
      &lt;res-ref-name&gt;jdbc/App_MySQL&lt;/res-ref-name&gt;
      &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
      &lt;res-auth&gt;Container&lt;/res-auth&gt;
  &lt;/resource-ref&gt;
  </code></pre>
  
  <p><strong>webapp/META-INF/context.xml:</strong></p>
  
  <pre><code>&lt;Context&gt;
      &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;
      &lt;ResourceLink name="jdbc/App_MySQL"
                    global="jdbc/App_MySQL"
                    type="javax.sql.DataSource"/&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p><strong>var/lib/tomcat7/conf:</strong></p>
  
  <pre><code>&lt;GlobalNamingResources&gt;
      &lt;Resource
                  name="jdbc/App_MySQL"
                  auth="Container"
                  type="javax.sql.DataSource"
                  username="root"
                  password="root_password"
                  driverClassName="com.mysql.jdbc.Driver"
                  description="App Database"
                  url="jdbc:mysql://localhost:3306/"
                  maxActive="15"
                  maxIdle="3"/&gt;
  
  &lt;/GlobalNamingResources&gt;
  </code></pre>
  
  <p><strong>Full error below:</strong></p>
  
  <pre><code>SEVERE: Unable to create initial connections of pool.
  java.sql.SQLException
      at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)
  </code></pre>