在Hadoop 1.2.1上创建用于运行MapReduce的jar

时间:2014-09-15 23:44:32

标签: hadoop mapreduce

我是Hadoop的新手,我刚在Mac笔记本电脑(Mavericks)上设置了Hadoop 1.2.1。然后我在IntelliJ IDEA中创建了一个简单的WordCount项目,并且能够在虚拟文本文件上运行代码。我在成功创建一个jar文件时遇到问题,该文件将通过IDE复制我的执行。我收到以下错误:

java -jar ./out/artifacts/WordCount_jar/WordCount.jar test.txt out [19:35:21]
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:146)
    at neu.cs.parallelprogramming.WordCount.main(WordCount.java:48)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more
FAIL: 1

有人能让我知道我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

我猜你必须指定你的类(它实现了Map / Reduce函数)。 例如,$ java -jar ./WordCount.jar classWordCount input.txt output$ hadoop jar yourprogram.jar **yourclass** inputpath outputpath