If you are trying to run a sample spring application first time you may face some problem.After ruuning your application If compiler give you the following error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.<init>(DefaultSingletonBeanRegistry.java:81) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.<init>(FactoryBeanRegistrySupport.java:43) at org.springframework.beans.factory.support.AbstractBeanFactory.<init>(AbstractBeanFactory.java:176) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:159) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:170) at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:166) at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:78) at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:67) at com.javatpoint.Test.main(Test.java:11) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 9 more
Oh! so much nasty lines in the error console, But don't worry you need not to read all the content in console. Just find out the line which start with Caused by: That line give you the potential information about the problem in your code. In the above error console if you go to the line Caused by: You will see java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory It means you don't have the above jar file in classpath.It is quite common error because if you just download the spring jars by googling.The Spring jar distribution does not contain the above jar.So you have to download it manually.Solution:In oreder to remove this error you have to download the following jar file com.springsource.org.apache.commons.logging-1.1.1 and add the downloaded jar file to the classpath to the project. Courtsey: Saajan Singh [Computer Science Graduate from HBTI Kanpur]
Comments
Post a Comment