为了账号安全,请及时绑定邮箱和手机立即绑定

c3p0的jar包已经加载正常,为何还报错说找不到com.mchange.v2.c3p0.ComboPooledDataSource

c3p0的jar包已经加载正常,为何还报错说找不到com.mchange.v2.c3p0.ComboPooledDataSource

而且在类中import时时可以找到这个类的。但是在spring+Hibernate配置数据源的时候,启动Tomcat就报错啊!!!

 

急急急急急急!!!!!

错误信息如下:

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.mchange.v2.c3p0.ComboPooledDataSource] for bean with name 'datasource' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.mchange.v2.c3p0.ComboPooledDataSource

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

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

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

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

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

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

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

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)

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

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

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

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5615)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)

at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1548)

at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1512)

at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1748)

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

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

at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)

at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1370)

at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1542)

at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1552)

at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1520)

at java.lang.Thread.run(Thread.java:619)

Caused by: java.lang.ClassNotFoundException: com.mchange.v2.c3p0.ComboPooledDataSource

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1891)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1734)

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

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

at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)

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

... 23 more

2017-2-8 16:18:09 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 [com.mchange.v2.c3p0.ComboPooledDataSource] for bean with name 'datasource' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.mchange.v2.c3p0.ComboPooledDataSource

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

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

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

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

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

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

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

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)

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

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

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

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5615)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)

at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1548)

at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1512)

at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1748)

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

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

at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)

at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1370)

at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1542)

at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1552)

at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1520)

at java.lang.Thread.run(Thread.java:619)

Caused by: java.lang.ClassNotFoundException: com.mchange.v2.c3p0.ComboPooledDataSource

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1891)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1734)

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

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

at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)

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

... 23 more


正在回答

9 回答

升级mybatis-spring版本号1.2.4,问题得到解决

0 回复 有任何疑惑可以回复我~

重新name 的名字, 再打前三个字母,使用Alt+/的方式提示选入即可  ,不行再加0.9.2.1的jar  包

0 回复 有任何疑惑可以回复我~

我也出现这样的问题,包什么的都导入了,已启动tomcat后就报错Caused by: java.lang.ClassNotFoundException: com.mchange.v2.c3p0.ComboPooledDataSourc

0 回复 有任何疑惑可以回复我~

因为spring在3.1之后的版本中把 AnnotationSessionFactoryBean与LocalSessionFactoryBean集成到了一起,统一用org\springframework\orm\hibernate4\LocalSessionFactoryBean。 不再有AnnotationSessionFactoryBean类; 但是org.springframework.orm-3.1.1.RELEASE.jar 依然保留有org\springframework\orm\hibernate3这个包,这是为了向下兼容。所以改成hibernate4即可!


0 回复 有任何疑惑可以回复我~

我解决了:
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.c3p0.ComboPooledDataSourc的解决问题
解决方法:1.导入c3p0-0.9.2.1.jar和mchange-commons-java-0.2.3.4.jar(有的导入就解决,有的还会报错,报错的看第二步)

2.对于<!-- 配置连接池 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><bean>中的class不能直接复制粘贴,要通过“提示”敲出来,如果直接复制或者不按提示敲出来可能还会继续报同样的错误

2 回复 有任何疑惑可以回复我~

楼主怎么解决的,分享一下

0 回复 有任何疑惑可以回复我~

楼主最后是怎么解决的?

0 回复 有任何疑惑可以回复我~
#1

仁夏

我解决了: Caused by: java.lang.ClassNotFoundException: com.mchange.v2.c3p0.ComboPooledDataSourc的解决问题 解决方法:1.导入c3p0-0.9.2.1.jar和mchange-commons-java-0.2.3.4.jar(有的导入就解决,有的还会报错,报错的看第二步)
2017-04-10 回复 有任何疑惑可以回复我~
#2

仁夏

2.对于<!-- 配置连接池 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><bean>中的class不能直接复制粘贴,要通过“提示”敲出来,如果直接复制或者不按提示敲出来可能还会继续报同样的错误
2017-04-10 回复 有任何疑惑可以回复我~
#3

漠燃 回复 仁夏

没有提示啊,包也导入了
2018-01-19 回复 有任何疑惑可以回复我~


和楼主 情况一样,我的解决办法是oracle的驱动jar包和数据库版本相同,db.properties文件中加载的驱动类为oracle.jdbc.OracleDriver,这是11g版本的,不行再换oracle.jdbc.driver.OracleDriver试试。

0 回复 有任何疑惑可以回复我~
#1

Night离 提问者

我是Mysql的,很奇怪的是,我再次创建一个工程,把所有的包都放在Liberary竟然也行,我想说如果再不行,干脆把所有的.jar包放到lib下面应该就可以了
2017-03-01 回复 有任何疑惑可以回复我~

很奇怪,我把c3p0的.jar包放在lib下面就行了,但是放在我自己创建的包就不行。。http://img1.sycdn.imooc.com//589ad7520001f33602400256.jpg

表示很奇怪。。。。

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

c3p0的jar包已经加载正常,为何还报错说找不到com.mchange.v2.c3p0.ComboPooledDataSource

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信