8

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.

user1516873
  • 5,060
  • 2
  • 37
  • 56
jvd
  • 175
  • 1
  • 4
  • 10

5 Answers5

11

Add this in your pom file:

<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.2</version>
</dependency>
Joao Luiz Cadore
  • 2,656
  • 1
  • 15
  • 11
1

It works for me after adding this jar file

commons-logging-1.2.jar

You can download it from here.

Oussama Ben Ghorbel
  • 2,132
  • 4
  • 17
  • 34
  • Excellent. Worked for me, but I would suggest downloading the jar directly from the maven repo ... https://mvnrepository.com/artifact/commons-logging/commons-logging/1.2. Or if you are able use Gradle/Maven as this is then automatic. –  Sep 11 '17 at 16:26
0

Include hibernate jar files (especially the required jars) in your lib folder

antlr-2.7.7.jar
commons-collections-3.2.1.jar
dom4j-1.6.1.jar
javassist-3.12.1.GA.jar
hibernate-core-4.0.1.Final.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
jboss-logging-3.1.0.CR2.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
bumbumpaw
  • 2,522
  • 1
  • 24
  • 54
0

I had a similar problem: In my project the solution was to add the following jars of org.apache.commons:

commons-logging-1.2 commons-dbcp2-2.1.1 commons-pool2-2.4.2

0

For me problem solved post download & adding jar "commons-logging-1.2.jar"