Cause of java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

here I have outlined some steps to fix "java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory" these are based on approach I used to resolve such kind of error. it may help you as well.
java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory Solution
1.Check your classpath for commons-logging-1.1.1.jar, if you are using spring MVC and working in web application it
must be on /WEB-INF/lib directory.
2.Check if your Java program has sufficient permission to access that jar file (I faced this issue in Unix machine
when user who copied that jar does override the default permission and application was not able to read this jar file
3.See if commons-logging-1.1.1.jar contains org.apache.commons.logging.LogFactory class or not this may happen if commons-logging-1.1.1.jar is corrupt or not downloaded completely or may be downloaded from incorrect source.
4.See if your Classpath is getting overridden by any start-up Script as suggested on my post how to solve java.lang.ClassNotFoundException
5.If you are using maven for managing dependency on your project than check if your pom.xml file contains following
entry or not and if it doesn't than include following dependency for commons-logging-1.1.1.jar in pom.xml:
Maven dependency for Apache commons-logging:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
That's all on How to fix java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory Error, it may surface as "Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory" also but mostly cause of both errors are same. If you have any other useful step to figure out ClassNotFoundException suggest it here.
Here are few more Java tutorials you may like.
No comments:
Post a Comment