You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-user@hadoop.apache.org by felix gao <gr...@gmail.com> on 2009/11/14 20:51:43 UTC

noobie question on hadoop's NoClassDefFoundError

I wrote a simple code in my eclipse as

Text t = new Text("hadoop");
System.out.println((char)t.charAt(2));

when I try to run this I got

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/logging/LogFactory
    at org.apache.hadoop.io.Text.<clinit>(Text.java:49)
    at com.example.io.WritableIOExample.main(WritableIOExample.java:44)
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    ... 2 more

The library used are Haddop 0.20.1 and log4j-1.2.15

Thanks for helping

Re: noobie question on hadoop's NoClassDefFoundError

Posted by felix gao <gr...@gmail.com>.
I got it. try to include all the jar files in the hadoop's lib and ivy
folder. It fixed mine.

On Tue, Nov 17, 2009 at 10:12 AM, Ratner, Alan S (IS)
<Al...@ngc.com>wrote:

>  I get a similar “NoclassDefFoundError” but it doesn’t involve Eclipse.  I
> have downloaded Hadoop 18.3, 19.1 and 20.1 and have gotten 18 and 19 to run
> on top of Cygwin.  But 20.1 doesn’t seem to be able to find Java, reports an
> exception in thread “main” java.lang.NoclassDefFoundError  and dies with the
> unhelpful message: “Could not find the main class: and.  Program will exit.”
>
>
>
> I have attached an image showing that the identical command (simply
> invoking bin/hadoop namenode -format) works in 18.3 and does not work in
> 20.1.  Does know why 20.1 differs this way from 18 and 19?
>
>
>
> Alan Ratner
>
>
>
>
>
> *From:* Jason Venner [mailto:jason.hadoop@gmail.com]
> *Sent:* Tuesday, November 17, 2009 1:26 AM
> *To:* mapreduce-user@hadoop.apache.org
> *Subject:* Re: noobie question on hadoop's NoClassDefFoundError
>
>
>
> Your eclipse instance doesn't have the jar files in the lib directory of
> your hadoop installation in the class path.
>
>  On Sat, Nov 14, 2009 at 7:51 PM, felix gao <gr...@gmail.com> wrote:
>
> I wrote a simple code in my eclipse as
>
> Text t = new Text("hadoop");
> System.out.println((char)t.charAt(2));
>
> when I try to run this I got
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/logging/LogFactory
>     at org.apache.hadoop.io.Text.<clinit>(Text.java:49)
>     at com.example.io.WritableIOExample.main(WritableIOExample.java:44)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.logging.LogFactory
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>     ... 2 more
>
> The library used are Haddop 0.20.1 and log4j-1.2.15
>
> Thanks for helping
>
>
>
>
> --
> Pro Hadoop, a book to guide you from beginner to hadoop mastery,
> http://www.amazon.com/dp/1430219424?tag=jewlerymall
> www.prohadoopbook.com a community for Hadoop Professionals
>

RE: noobie question on hadoop's NoClassDefFoundError

Posted by "Ratner, Alan S (IS)" <Al...@ngc.com>.
I get a similar "NoclassDefFoundError" but it doesn't involve Eclipse.
I have downloaded Hadoop 18.3, 19.1 and 20.1 and have gotten 18 and 19
to run on top of Cygwin.  But 20.1 doesn't seem to be able to find Java,
reports an exception in thread "main" java.lang.NoclassDefFoundError
and dies with the unhelpful message: "Could not find the main class:
and.  Program will exit."

 

I have attached an image showing that the identical command (simply
invoking bin/hadoop namenode -format) works in 18.3 and does not work in
20.1.  Does know why 20.1 differs this way from 18 and 19?

 

Alan Ratner

 

 

From: Jason Venner [mailto:jason.hadoop@gmail.com] 
Sent: Tuesday, November 17, 2009 1:26 AM
To: mapreduce-user@hadoop.apache.org
Subject: Re: noobie question on hadoop's NoClassDefFoundError

 

Your eclipse instance doesn't have the jar files in the lib directory of
your hadoop installation in the class path.



On Sat, Nov 14, 2009 at 7:51 PM, felix gao <gr...@gmail.com> wrote:

I wrote a simple code in my eclipse as 

Text t = new Text("hadoop");
System.out.println((char)t.charAt(2));

when I try to run this I got 

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/logging/LogFactory
    at org.apache.hadoop.io.Text.<clinit>(Text.java:49)
    at com.example.io.WritableIOExample.main(WritableIOExample.java:44)
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    ... 2 more

The library used are Haddop 0.20.1 and log4j-1.2.15

Thanks for helping




-- 
Pro Hadoop, a book to guide you from beginner to hadoop mastery,
http://www.amazon.com/dp/1430219424?tag=jewlerymall
www.prohadoopbook.com a community for Hadoop Professionals


Re: noobie question on hadoop's NoClassDefFoundError

Posted by Jason Venner <ja...@gmail.com>.
Your eclipse instance doesn't have the jar files in the lib directory of
your hadoop installation in the class path.


On Sat, Nov 14, 2009 at 7:51 PM, felix gao <gr...@gmail.com> wrote:

> I wrote a simple code in my eclipse as
>
> Text t = new Text("hadoop");
> System.out.println((char)t.charAt(2));
>
> when I try to run this I got
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/logging/LogFactory
>     at org.apache.hadoop.io.Text.<clinit>(Text.java:49)
>     at com.example.io.WritableIOExample.main(WritableIOExample.java:44)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.logging.LogFactory
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>     ... 2 more
>
> The library used are Haddop 0.20.1 and log4j-1.2.15
>
> Thanks for helping
>



-- 
Pro Hadoop, a book to guide you from beginner to hadoop mastery,
http://www.amazon.com/dp/1430219424?tag=jewlerymall
www.prohadoopbook.com a community for Hadoop Professionals