Tuesday, December 10, 2019

How To Cook Java.Lang.Classnotfoundexception: Org.Apache.Commons.Logging.Logfactory

Problem : You are getting java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory inwards your Java program, which uses logging framework to log messages into log file.  It could endure take away dependency or indirect dependency due to whatever framework e.g. Spring, Hibernate or whatever opened upwardly root library similar jackson or whatever other JSON parsing library.


Cause : java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory error comes when y'all are using Apache common logging straight or indirectly using framework similar Hibernate, Spring as well as commons-logging-1.1.2.jar is non available inwards CLASSPATH. Sometime this may endure due to roughly nasty classpath issue, only most oftentimes this is due to missing JAR inwards the classpath.


Solution : If its illustration of missing JAR file as well as thus final result volition endure solved every bit shortly every bit y'all deploy the commons-logging-1.1.1.jar or commons-logging-1.1.2.jar inwards CLASSPATH, only deploying JAR manually is dull as well as mistake prone. You involve to outset give away those JAR files on mesh as well as and thus promise that at that spot is no version mismatch mistake e.g. suppose your Spring or Hibernate version is using Apache common logging version 1.1.2 as well as y'all deployed version 1.1.1, y'all mightiness non honor whatever mistake upfront only it volition neglect inwards production every bit shortly every bit novel characteristic which is alone available inwards commons-logging-1.1.2.jar is triggered. That's why its best to use Maven to download as well as contend dependency JAR files. Maven volition non alone automatically download the JAR file for y'all only likewise it volition ensure that right version of transitive subject JARs are downloaded.



In companionship to add together common logging JAR using Maven, y'all tin add together next dependency inwards your pom.xml

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

If y'all are using Maven inwards Eclipse using M2Eclipse plugin, You tin fifty-fifty search as well as add together dependencies similar below :

 which uses logging framework to log messages into log file How to cook java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory


For manual download, y'all tin become to maven fundamental website as well as download commons-logging.jar file.
http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.2/commons-logging-1.1.2.jar

You tin fifty-fifty download apache common logging JARs from Apache Commons Logging website every bit well, http://commons.apache.org/logging/download_logging.cgi every bit well.


That's all nigh how to cook java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory mistake inwards Java. It tin come upwardly fifty-fifty if y'all are non using common logging dirctly only using a library similar Spring, Hibernate, or Struts, which internally uses this library for their logging need. This mistake should endure fixed every bit shortly every bit y'all set commons-logging-1.1.1.jar file inwards your CLASSPATH. If y'all run into this mistake fifty-fifty afterwards having commons-logging.jar as well as thus it agency your CLASSPATH is non laid properly. Follow steps given inwards this article to setup your CLASSPATH properly.

Further Learning
Complete Java Masterclass
solution]
  • How to solve java.lang.NoClassDefFoundError: org/dom4j/DocumentException [solution
  • What is divergence betwixt ClassNotFoundException as well as NoClassDefFoundError inwards Java? [answer]
  • How to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver inwards Java? [answer]
  • How to cook java.lang.unsupportedclassversionerror unsupported major.minor version 49.0 50.0 51.0 inwards Java [solution]
  • How to Fix java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver [solution
  • 'javac' is non recognized every bit an internal or external command, operable plan or batch file [solution]
  • No comments:

    Post a Comment