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

与世无争的帅哥 提交于 2019-11-27 06:51:05

问题


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.


回答1:


Add this in your pom file:

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



回答2:


It works for me after adding this jar file

commons-logging-1.2.jar

You can download it from here.




回答3:


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



回答4:


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




回答5:


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



来源:https://stackoverflow.com/questions/24796112/how-to-fix-classnotfoundexception-org-apache-commons-logging-logfactory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!