JDBC tomcat连接池不工作



Apache tomcat log

july19, 2014 9:31:31 PM org.apache.catalina.core.StandardWrapperValve为servlet [FrontController]调用SEVERE: servlet .service()context with path [/GroupFound]抛出异常java.lang.ClassCastException:不能将basicdatasource强制转换为org.apache.tomcat.jdbc.pool.DataSource在models.bean.Customer.act (Customer.java: 32)controller.FrontController.processRequest (FrontController.java: 40)controller.FrontController.doGet (FrontController.java: 61)javax.servlet.http.HttpServlet.service (HttpServlet.java: 621)javax.servlet.http.HttpServlet.service (HttpServlet.java: 722)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java: 305)在org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java: 210)在org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter (MonitorFilter.java: 393)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java: 243)在org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java: 210)在org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java: 225)在org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java: 169)在org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java: 472)在org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java: 168)在org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java: 98)在org.apache.catalina.valves.AccessLogValve.invoke (AccessLogValve.java: 927)在org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java: 118)在org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java: 407)在org.apache.coyote.http11.AbstractHttp11Processor.process (AbstractHttp11Processor.java: 999)在org.apache.coyote.AbstractProtocol AbstractConnectionHandler.process美元(AbstractProtocol.java: 565)在org.apache.tomcat.util.net.JIoEndpoint SocketProcessor.run美元(JIoEndpoint.java: 307)在java.util.concurrent.ThreadPoolExecutor Worker.runTask美元(ThreadPoolExecutor.java: 886)在java.util.concurrent.ThreadPoolExecutor Worker.run美元(ThreadPoolExecutor.java: 908)java.lang.Thread.run (Thread.java: 662)

误差

org.apache.tomcat.dbcp.dbcp。SQLNestedException: Cannot create JDBC类的驱动程序"为连接URL 'null'在org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory (BasicDataSource.java: 1452)在org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource (BasicDataSource.java: 1371)在org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection (BasicDataSource.java: 1044)(Customer.java:33controller.FrontController.processRequest (FrontController.java: 40)controller.FrontController.doGet (FrontController.java: 61)javax.servlet.http.HttpServlet.service (HttpServlet.java: 621)javax.servlet.http.HttpServlet.service (HttpServlet.java: 722)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java: 305)在org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java: 210)在org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter (MonitorFilter.java: 393)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java: 243)在org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java: 210)在org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java: 225)在org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java: 169)在org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java: 472)在org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java: 168)在org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java: 98)在org.apache.catalina.valves.AccessLogValve.invoke (AccessLogValve.java: 927)在org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java: 118)在org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java: 407)在org.apache.coyote.http11.AbstractHttp11Processor.process (AbstractHttp11Processor.java: 999)在org.apache.coyote.AbstractProtocol AbstractConnectionHandler.process美元(AbstractProtocol.java: 565)在org.apache.tomcat.util.net.JIoEndpoint SocketProcessor.run美元(JIoEndpoint.java: 307)在java.util.concurrent.ThreadPoolExecutor Worker.runTask美元(ThreadPoolExecutor.java: 886)在java.util.concurrent.ThreadPoolExecutor Worker.run美元(ThreadPoolExecutor.java: 908)java.lang.Thread.run(Thread.java:662)java.lang.NullPointerException在sun.jdbc.odbc.JdbcOdbcDriver.getProtocol (JdbcOdbcDriver.java: 507)sun.jdbc.odbc.JdbcOdbcDriver.knownURL (JdbcOdbcDriver.java: 476)sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL (JdbcOdbcDriver.java: 307)java.sql.DriverManager.getDriver (DriverManager.java: 253)org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory (BasicDataSource.java: 1437)…26日更多

context.xml从META-INF文件夹更改。Catalina -home/conf/Catalina/localhost/[projectname].xml在更改META-INF copy时也被更改。

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/GroupFound">
<Resource auth="Container" 
defaultReadOnly="false" 
driverClassName="com.mysql.jdbc.jdbc2.optional" 
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" 
initialSize="0" 
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer" 
jmxEnabled="true" 
logAbandoned="true" 
maxActive="300" maxIdle="50"
maxWait="10000" 
minEvictableIdleTimeMillis="300000"
minIdle="30" 
name="jdbc/testcp"
password="" 
removeAbandoned="true"
removeAbandonedTimeout="60" 
testOnBorrow="true"
testOnReturn="false" 
testWhileIdle="true" 
timeBetweenEvictionRunsMillis="30000"
type="javax.sql.DataSource" 
url="jdbc:mysql://localhost:3306/test" 
username="root"
validationInterval="30000" 
validationQuery="SELECT 1"/>
</Context>

web . xml从应用程序上下文更改(netbeans IDE)

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>FrontController</servlet-name>
<servlet-class>controller.FrontController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FrontController</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>/jdbc/testcp</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>

几个小时以来我一直在试图修复它。搜索谷歌和类似的问题没有成功。我累坏了。如何解决这个问题?我只是想看到DataSource工作。

JDK 6.1netbeans 7.2tomcat 7.0.27

这似乎是我能找到的最好的指南:

http://tomcat.apache.org/tomcat - 7.0 - doc/jndi数据源实例howto.html

一个快速的测试是把它放在这里:

CATALINA_BASE/conf/context.xml美元

相关内容

  • 没有找到相关文章

最新更新