'java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

I install Hadoop-0.20.2 in windows using cygwin. If i run

 $ bin/hadoop version
Hadoop 0.20.2
Subversion https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20 -r 911707
Compiled by chrisdo on Fri Feb 19 08:07:34 UTC 2010

It Works Properly but If I run

namenode -format

it will return error like below

$ bin/hadoop namenode -format
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
        at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:139)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.<clinit>(NameNode.java:101)
Exception in thread "main"

Kindly help me to solve the issue



Solution 1:[1]

If you using this lib org.apache.commons.logging.LogFactory then you should probably initialize log according to classes @ coding

Example

private static Log LOG = LogFactory.getLog(ClassName.class);

It has .class extension when compile you should make sure whether that class created or not else it will give an exception, i guess

Check the classpath too

Issue-java.lang.NoClassDefFoundError

Root Cause: Incorrect Java path set in Environment Variable Section

Solution: Set correct JAVA_HOME Path

Steps->Environment Variable Setting (My Comp-Right Click ->Properties->Env Variable->Advance Tab ->Variable)

Create new JAVA_HOME Environment Variable.

JAVA_HOME .;C:\Program Files (x86)\Java\jdk1.6.0_14

Set JAVA_HOME variable in PATH Variable section.

PATH %JAVA_HOME%\bin

Set JAVA_HOME variable in CLASSPATH Variable

CLASSPATH %JAVA_HOME%\jre\lib

Restart System

Verify all variable

echo %CLASSPATH%

echo %JAVA_HOME%

echo %PATH%

Compile & Run the program

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1