Exception logging and processing-cannot find class [Org.apache.commons.dbcp.BasicDataSource]

Source: Internet
Author: User

Exception description

The following exception occurred while using spring to obtain the JDBC connection, which was analyzed to be locked to Org.apache.commons.dbcp.BasicDataSource (red font)

Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' Userdao ': Injection of resource Dependencies failed;

Nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: cannot find class [ Org.apache.commons.dbcp.BasicDataSource] for beans with the name ' DataSource ' defined in class path resource [Conn.xml];

Nested exception is java.lang.ClassNotFoundException:org.apache.commons.dbcp.BasicDataSource


At Org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues ( commonannotationbeanpostprocessor.java:311)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean ( abstractautowirecapablebeanfactory.java:1214)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:543)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:482)
At Org.springframework.beans.factory.support.abstractbeanfactory$1.getobject (abstractbeanfactory.java:306)
At Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:230)
At Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:302)
At Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:197)
At Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:772)
At Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization ( abstractapplicationcontext.java:839)
At Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:538)
At Org.springframework.context.support.classpathxmlapplicationcontext.<init> ( classpathxmlapplicationcontext.java:139)
At Org.springframework.context.support.classpathxmlapplicationcontext.<init> ( CLASSPATHXMLAPPLICATIONCONTEXT.JAVA:83)
At DataSource. Connectiontest.test (CONNECTIONTEST.JAVA:14)
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:57)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:43)
At Java.lang.reflect.Method.invoke (method.java:601)
At Org.junit.runners.model.frameworkmethod$1.runreflectivecall (frameworkmethod.java:45)
At Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:15)
At org.junit.runners.model.FrameworkMethod.invokeExplosively (frameworkmethod.java:42)
At Org.junit.internal.runners.statements.InvokeMethod.evaluate (invokemethod.java:20)
At Org.junit.runners.ParentRunner.runLeaf (parentrunner.java:263)
At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:68)
At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:47)
At Org.junit.runners.parentrunner$3.run (parentrunner.java:231)
At Org.junit.runners.parentrunner$1.schedule (parentrunner.java:60)
At Org.junit.runners.ParentRunner.runChildren (parentrunner.java:229)
At org.junit.runners.parentrunner.access$000 (parentrunner.java:50)
At Org.junit.runners.parentrunner$2.evaluate (parentrunner.java:222)
At Org.junit.runners.ParentRunner.run (parentrunner.java:300)
At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:50)
At Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:467)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:683)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:390)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:197)

Caused by:org.springframework.beans.factory.CannotLoadBeanClassException:cannot find class [Org.apache.commons.dbcp.BasicDataSource]For beans with the name ' DataSource ' defined in class path resource [Conn.xml]; Nested exception is Java.lang.ClassNotFoundException:org.apache.commons.dbcp.BasicDataSource
At Org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass (abstractbeanfactory.java:1352 )
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:455)
At Org.springframework.beans.factory.support.abstractbeanfactory$1.getobject (abstractbeanfactory.java:306)
At Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:230)
At Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:302)
At Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:202)
At Org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource ( COMMONANNOTATIONBEANPOSTPROCESSOR.JAVA:512)
At Org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource ( commonannotationbeanpostprocessor.java:486)
At Org.springframework.context.annotation.commonannotationbeanpostprocessor$resourceelement.getresourcetoinject (commonannotationbeanpostprocessor.java:615)
At Org.springframework.beans.factory.annotation.injectionmetadata$injectedelement.inject (InjectionMetadata.java : 178)
At Org.springframework.beans.factory.annotation.InjectionMetadata.inject (injectionmetadata.java:88)
At Org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues ( commonannotationbeanpostprocessor.java:308)
... More
caused By:java.lang.ClassNotFoundException:org.apache.commons.dbcp.BasicDataSource
At Java.net.urlclassloader$1.run (urlclassloader.java:366)
At Java.net.urlclassloader$1.run (urlclassloader.java:355)
At java.security.AccessController.doPrivileged (Native Method)
At Java.net.URLClassLoader.findClass (urlclassloader.java:354)
At Java.lang.ClassLoader.loadClass (classloader.java:423)
At Sun.misc.launcher$appclassloader.loadclass (launcher.java:308)
At Java.lang.ClassLoader.loadClass (classloader.java:356)
At Org.springframework.util.ClassUtils.forName (classutils.java:250)
At Org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass ( abstractbeandefinition.java:394)
At Org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass (Abstractbeanfactory.java : 1397)
At Org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass (abstractbeanfactory.java:1344 )
... More

Exception resolution:

Keyword: cannot find class [Org.apache.commons.dbcp.BasicDataSource]

The class could not be found because of the lack of commons-pool and commons-dbcp two packages, just add these two packages under the Classpath

Link

Conmons-dbcp-1.2.jar Download

Commons-pool-1.6.jar Download

Exception logging and processing-cannot find class [Org.apache.commons.dbcp.BasicDataSource]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.