Java错误,java.lang.NoClassDefFoundError:Hadoop中的org / myorg / WordCount

时间:2013-04-08 14:31:29

标签: java hadoop

我对Hadoop很新。我遵循了关于如何在hadoop中创建字数统计程序的基础教程。一切都很好。我试图创建自己的地图reduce,并将其放在一个单独的jar文件中。当我试图运行该程序时,它给了我这个错误:

shean@ubuntu-PC:~/hadoop/bin$ hadoop jar ../weather.jar weather.Weather /user/hadoop/weather_log_sample.txt /user/hadoop/output
Warning: $HADOOP_HOME is deprecated.

Exception in thread "main" java.lang.NoClassDefFoundError: org/myorg/WordCount
    at weather.Weather.main(Weather.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
Caused by: java.lang.ClassNotFoundException: org.myorg.WordCount
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    ... 6 more

但问题是,它正在寻找WordCount类......

2 个答案:

答案 0 :(得分:1)

如果我没错,你错过了jar wordcount.jar。请将其添加到build path.

答案 1 :(得分:0)

我的建议:你先把“包”路径删除了。这样可以更容易地报告NoClassDefFoundError错误。 javac编译时间:javac-classpath“$ HADOOP_HOME / hadoop-core-1.2.0.jar:$ HADOOP_HOME / lib / commons-cli-1.2.jar”-d。 /天气

litianmin@gmail.com