Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix ClassNotFoundException: org.apache.commons.logging.LogFactory?

When i run the app it getting exception

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.hibernate.dialect.Dialect.<clinit>(Dialect.java:58)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 1 more

I have put all the jar files in lib folder. I don't know how to solve this, where is my mistake.

like image 328
jvd Avatar asked Jul 17 '14 06:07

jvd


People also ask

How do I download Apache Commons Logging?

jar : org apache « o « Jar File Download. The download jar file contains the following class files or Java source files.

What is Exception in thread main Java Lang NoClassDefFoundError?

lang. NoClassDefFoundError is a common error in Java that occurs if a ClassLoader cannot find a particular class in the classpath while trying to load it. The Exception in thread "main" suggests that this error has occurred in the main thread, the thread which is responsible for running the Java application.


2 Answers

Add this in your pom file:

<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.2</version>
</dependency>
like image 150
Joao Luiz Cadore Avatar answered Oct 03 '22 01:10

Joao Luiz Cadore


It works for me after adding this jar file

commons-logging-1.2.jar

You can download it from here.

like image 30
Kishore Babu Avatar answered Oct 03 '22 02:10

Kishore Babu