java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource的解決方法

用Myeclipse开发struts时,配置struts-config中的data-sources,出现java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource的解决方法
struts-config.xml文件中的data-sources是这样配置的

  1. <data-sources>
  2. <data-source key="mysql" type="org.apache.commons.dbcp.BasicDataSource">
  3. <set-property property="autoCommit" value="true"/>
  4. <set-property property="driverClassName" value="com.mysql.jdbc.Driver"/>
  5. <set-property property="url" value="jdbc:mysql://localhost:3306/javajavajava"/>
  6. <set-property property="maxCount" value="10"/>
  7. <set-property property="minCount" value="1"/>
  8. <set-property property="username" value="root"/>
  9. <set-property property="password" value="admin"/>
  10. </data-source>
  11. </data-sources>

启动Tomcat,结果出现下面的错误:

信息: Starting Servlet Engine: Apache Tomcat/6.0.13
2007-12-17 19:31:06 org.apache.struts.action.ActionServlet initModuleDataSources
严重: Initializing application data source mysql
java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:117)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:805)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4042)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2007-12-17 19:31:06 org.apache.catalina.core.ApplicationContext log
信息: Marking servlet action as unavailable
2007-12-17 19:31:06 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /huqianhao threw load() exception
javax.servlet.UnavailableException: Initializing application data source mysql
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:812)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4042)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2007-12-17 19:31:06 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2007-12-17 19:31:07 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2007-12-17 19:31:07 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/63 config=null
2007-12-17 19:31:07 org.apache.catalina.startup.Catalina start
信息: Server startup in 2848 ms

一看就知道是没有找到文件,但不知道是少了哪个jar包。网上搜了一下,只要把commons-pool.jar、commons-dbcp-1.2.2.jar和commons-collections-3.2.jar三个jar包加入classpath中就没问题拉!有人说只要前两个,我试了下好象不行哦。这几个jar包都可以在myeclipse安装文件下可以找到。只是版本号可能不一样而已Ctrl+F查找一下就OK拉!

更多相关文章
一周排行
  • 如果想让某一段代码在前台不显示,最简单的方法是用css的display:none即可,这样下边的内容就自动上移或右侧的左移来填补这个空隙.但特殊情况下我们只需要隐藏这个元素, 但它的位置不能被占了,那该怎么实现呢?接
  • 


    		    /tmp分區滿,把oracle rac弄死了
    刚从山东回来,一堆麻烦事情.这不,快要下班了,客户说oracle rac挂了. 这是有两个 ...
  • 


    		    使用JVisualVM遠程監控Tomcat
    用JVisualVM连接远程JVM,监控系统运行性能参数. 作用:JVM和监控的应用程序运 ...
  • 


    		    DataNode與NameNode交互機制相關代碼分析
    HDFS Federation是为解决HDFS单点故障而提出的NameNode水平扩展方案
  • catalog 1. INTRODUCTION 2. THE PROCESS IMAGE 3. THE CORE IMAGE 4. EXECUTABLE RECONSTRUCTION 5. FAILURES IN R ...
  • 书:深入体验Java_Web开发内幕-核心基础 上面有几张阐述tomcat使用比较清晰,比tomcat权威指南等更实用.
  • 1.安装 yum install -y gitweb 2.配置 vim /etc/gitweb.conf 添加 $projectroot = "/data/git/repositories"; a ...
  • Largest Rectangle in a Histogram(DP)
    Largest Rectangle in a Histogram Time Limit : ...
  • moo的Hessian总线的数据通信模式大致为:      Hessian 格式:基于二进制格式的用于网络传输的协议.Hessian格式数据流的是实现 java.io.Serializable接口.当两个进程在进行远
  •   前言:什么是memoryCache? 一种缓存管理技术,某些只读数据频繁操作数据库,会对系统的性能有很大的开销,所以我们使用缓存技术,当数据库内容更新,我们在更更新缓存的数据值.目前缓存讲技术的产品很多,常用的主