Tomcat Unable to create initial connections of pool

眉间皱痕 提交于 2019-12-22 00:31:42

问题


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.

pom.xml:

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.36</version>
        <scope>provided</scope>
    </dependency>

webapp/WEB-INF/web.xml:

<resource-ref>
    <description>App MySQL</description>
    <res-ref-name>jdbc/App_MySQL</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

webapp/META-INF/context.xml:

<Context>
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <ResourceLink name="jdbc/App_MySQL"
                  global="jdbc/App_MySQL"
                  type="javax.sql.DataSource"/>
</Context>

var/lib/tomcat7/conf:

<GlobalNamingResources>
    <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"/>

</GlobalNamingResources>

Full error below:

SEVERE: Unable to create initial connections of pool.
java.sql.SQLException
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)

来源:https://stackoverflow.com/questions/31288947/tomcat-unable-to-create-initial-connections-of-pool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!