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拉!

更多相关文章
一周排行
  • <!DOCTYPE html> <html> <body> <script> // validate thether this browser support stor ...
  • USACO 2012 JAN(题目一) 一.题目概览 中文题目名称 礼物 配送路线    游戏组合技 英文题目名称 gifts delivery combos 可执行文件名 gifts delivery combos
  • PW 7.5SP3完美转换DZ 7.2视频教程 http://d.namipan.com/d/ca24da2b0d9ec4f63380bbd204337076608f991880f23603 本文出自 "哭 ...
  • 将dll文件覆盖安装目录下的文件,之后用算号器算出license文件,将license文件放在安装目录下即可. 算号器是在http://www.dxper.net/thread--1.html这儿下载的.感 ...
  • ASEDaily Scrum12.15
    这两周事情好多~ 组里面的事情,出国的申请出国…………   不过整体来说我们sprint3
  • 思路别人那里讲的很清楚了,我就不阐述了.链接 1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #includ ...
  • 


    		    Aruba IAP 93的基于外部伺服器的MAC認證
    时间太紧张 写个贴总结下今天的东西 好吧 That's all!(用live writer
  • 有时候在执行SQL查询语句时,仅仅需要知道检索的元数据,而不是具体的数据行,可以设置SET FMTONLY ON. SET FMTONLY只将元数据返回给客户端.语法SET FMTONLY { ON OFF }注释当
  • 由于互相憎恨的骑士不能相邻,把可以相邻的骑士连上无向边,会议要求是奇数,问题就是求不在任意一个简单奇圈上的结点个数. 如果不是二分图,一定存在一个奇圈,且其他点一定可以加入这个奇圈. tarjan直接套以前写的,结果 ...
  • ARP攻击原理及解决方法与CMD命令 [故障原因] 局域网内有人使用ARP欺骗的木马程序(比如:传奇盗号的软件,某些传奇外挂中也被恶意加载了此程序). [故障原理] 要了解故障原理,我们先来了解一下ARP协议. 在局 ...