iteye_14821
2010-07-25 15:48
浏览 443
已采纳

ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

贴上代码:

 

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">

<property name="driverClassName">

<value>com.mysql.jdbc.Driver</value>

</property>

<property name="url">

<value>jdbc:mysql://localhost:3306/bbs</value>

</property>

<property name="username">

<value>root</value>

</property>

<property name="password">

<value>123456</value>

</property>

</bean>

 

我用到的包:




启动tomacat报异常:

 

 

严重: Context initialization failed

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)

at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)

at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)

at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)

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:526)

at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)

at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556)

at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)

at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)

at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)

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:583)

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)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)

at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)

at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)

... 33 more

2010-7-25 15:27:02 org.apache.catalina.core.StandardContext listenerStart

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)

at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)

at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)

at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)

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:526)

at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)

at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556)

at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)

at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)

at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)

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:583)

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)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)

at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)

at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)

... 33 more

2010-7-25 15:27:02 org.apache.catalina.core.StandardContext start

严重: Error listenerStart

2010-7-25 15:27:02 org.apache.catalina.core.StandardContext start

严重: Context [] startup failed due to previous errors


  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • haha662 2010-07-25 18:17
    已采纳

    把你的commons-pool.jar、commons-dbcp-1.2.2.jar和commons-collections-3.2.jar这三个包,打开看下有没org.apache.commons.dbcp.BasicDataSource,如果有的话,那就是你的包版本不一样

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题