[Java] NoClassDefFoundError Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory


Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:119)
    at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:55)
    ....
    at com.client.StoryReader.main(StoryReader.java:15)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ....
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 6 more

If you receive the above NoClassDefFoundError -> ClassNotFoundException stack trace when you run your Java application that is using Apache commons-logging framework, for example commons-logging-1.1.2.jar then maybe you have missed adding this dependency in your pom.xml file,

Add the following dependency in your Maven pom.xml file,

<dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2.0</version>
</dependency>

You can download the latest Apache common logging jar from their website: http://commons.apache.org/proper/commons-logging/download_logging.cgi

Adding this dependency will solve your problem!

ClassNotFoundException org.apache.commons.logging.LogFactory Java Exception
ClassNotFoundException org.apache.commons.logging.LogFactory Java Exception
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap