1

我试图通过 Mysql 连接在 tomcat6 中部署 web 应用程序,我手动将 tomcat-jdbc 文件 v1.1.0.1 上传到tomcat/lib/但应用程序无法启动,

在此处复制了日志文件的最后几行:

Mar 2, 2013 11:10:06 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [] startup failed due to previous errors
Mar 2, 2013 11:15:36 AM org.apache.naming.NamingContext lookup
WARNING: Unexpected exception resolving reference
java.sql.SQLException: com.mysql.jdbc.Driver
        at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:243)
        at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:176)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:653)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:595)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:458)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:130)
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:99)
        at org.apache.tomcat.jdbc.pool.DataSourceFactory.createDataSource(DataSourceFactory.java:499)
        at org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:222)
        at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1028)
        at org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:637)
        at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:238)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4612)
        at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1276)
        at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:625)
        at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:136)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:194)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:236)
        ... 40 more
Mar 2, 2013 11:15:36 AM org.apache.catalina.core.NamingContextListener
addResource
WARNING: Failed to register in JMX: javax.naming.NamingException:
com.mysql.jdbc.Driver
Mar 2, 2013 11:15:36 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Mar 2, 2013 11:15:36 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [] startup failed due to previous errors

====

这是我的 contex.xml 文件

<Resource name="jdbc/AmbraDS"
    auth="Container"
    type="javax.sql.DataSource"
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    validationQuery="SELECT 1"
    testOnBorrow="true"
    driverClassName="com.mysql.jdbc.Driver"
    username="test"
    password="test"
    url="jdbc:mysql://localhost:3306/test"/>

使用的jar文件是:

 apache-tomcat-jdbc-1.1.0.1-src

似乎与 MySQL 连接有问题,有人可以帮我解决这个问题吗?

4

2 回答 2

1

从http://dev.mysql.com/downloads/connector/j/下载 jdbc 驱动程序

它需要在 catalinahome/lib

于 2013-03-02T12:26:50.167 回答
0

我认为存在一些冲突。例如,如果您有 2 个位置,一个有 JDBC 驱动程序,而另一个没有,那么如果您的类加载器从第一个位置加载并且第一个位置的某个类想要使用驱动程序 - 驱动程序不存在。因此,请查找使用您的驱动程序的重复 JAR

于 2013-03-02T12:24:01.977 回答