The Artima Developer Community
Sponsored Link

Java Buzz Forum
org.apache.commons.logging.LogFactory Error ClassNotFoundException

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
org.apache.commons.logging.LogFactory Error ClassNotFoundException Posted: Feb 8, 2012 8:17 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: org.apache.commons.logging.LogFactory Error ClassNotFoundException
Feed Title: Javarevisited Blog
Feed URL: http://javarevisited.blogspot.com/feeds/posts/default?alt=rss
Feed Description: Blog on Java, Unix, Linux, FIX Protocol technology. I share my experience as tutorial, article, interview questions, programming, design etc.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Javarevisited Blog

Advertisement
java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory  or "Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory" exception comes when you don't apache commons-logging-1.1.1.jar in your Classpath. I have faced this exception many times while using open source framework like Struts, Spring and Displaytag which uses commons-logging framework for logging. commons-logging is not an actual java logging framework but provides a wrapper so that you can use log4j, java logging or any other Java logging framework. commons-logging is also smart enough to detect which logging framework are you using e.g if you are using log4j it can detect it by looing log4j.jar in your classpath. but if you don't have commons-logging.jar in your classpath you may get java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at runtime even if your application gets deployed successfully.

Cause of java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory ErrorReal cause of "Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory" or "java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory" is JVM not able to locate commons-logging-1.1.1.jar in classpath but it may surface differently on different environment. Some time even you get this error even if you already have commons-logging-1.1.1.jar in classpath and many times it differnt reasons for different envornment. It gets more difficult on managed environment like J2EE web servers and application servers where different classloader loads differnet classes e.g. AppClassLoader is responsible for loading web application but classes inside lib directory of web server e.g. tomcat is loaded by another classloader. So you can also get "java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory" if commons-logging.jar is not visible to App classloader. some times this jar can also cause memory leak in tomcat.

here I have outlined some steps to fix "java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory" these are based on approach I used to resolve such kind of error. it may help you as well.

java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory Solution

1.Check your classpath for commons-logging-1.1.1.jar, if you are using spring MVC and working in web application it
must be on /WEB-INF/lib directory.

2.Check if your Java program has sufficient permission to access that jar file (I faced this issue in Unix machine
when user who copied that jar does override the default permission and application was not able to read this jar file
so make sure to check permissions if you are copying commons-logging-1.1.1.jar into Java Classpath.

3.See if commons-logging-1.1.1.jar contains org.apache.commons.logging.LogFactory class or not this may happen if commons-logging-1.1.1.jar is currupt or not downloaded completely or may be downloaded from incorrect source.

4.See if your Classpath is getting overriden by any start-up Script as suggested on my post how to solve java.lang.ClassNotFoundException

5.If you are using maven for managing dependency on your project than check if your pom.xml file contians following
entry or not and if it doesn't than include following dependency for commons-logging-1.1.1.jar in pom.xml:
Maven dependecny for Apache commons-logging:

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


That's all on How to fix java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory Error, it may surface as "Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory" also but mostly cause of both errors are same. If you have any other useful step to figure out ClassNotFoundException suggest it here.

Here are few more Java tutorials you may like.



Read: org.apache.commons.logging.LogFactory Error ClassNotFoundException

Topic: Java 7: Copy and Move Files and Directories Previous Topic   Next Topic Topic: Are you obsessed with testing ?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use