9

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.

4
  • 3
    You have also added the commons-logging.jar? Commented Jul 17, 2014 at 6:16
  • 3
    This has nothing to do with Hibernate, you don't have Log4J on your classpath, and Hibernate expects Log4J to be available. Commented Jul 17, 2014 at 6:16
  • Consider using a framework like Maven, which will automatically download all necessary dependencies for you. Commented Jul 17, 2014 at 6:18
  • You should put commons-logging.jar in lib folder. Commented Jul 17, 2014 at 7:26

5 Answers 5

11

Add this in your pom file:

<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.2</version>
</dependency>
Sign up to request clarification or add additional context in comments.

1 Comment

for me it worked with <version>1.1.1</version> instead
1

It works for me after adding this jar file

commons-logging-1.2.jar

You can download it from here.

1 Comment

Excellent. Worked for me, but I would suggest downloading the jar directly from the maven repo ... mvnrepository.com/artifact/commons-logging/commons-logging/1.2. Or if you are able use Gradle/Maven as this is then automatic.
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

Comments

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

1 Comment

downvoting with no explanation. terrible attitude
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.