我是hadoop新手。我正在使用pig0.14.0和hadoop1.2.1。我已经成功地从gruntshell和pig批处理脚本在本地和map reduce模式下运行了pig。现在我正在尝试从java中嵌入的pig运行pig。在eclipse中编译代码时,出现以下错误:
线程“main”java.lang.noclassdeffounderror中出现异常:org/apache/commons/logging/logfactory,位于org.apache.pig.impl.util.propertiesutil.(propertiesutil)。java:34)在org.apache.pig.pigserver.(pigserver。java:202)测试主(测试。java:6)原因:java.lang.classnotfoundexception:org.apache.commons.logging.logfactory atjava.net.urlclassloader$1.run(urlclassloader。java:366)在java.net.urlclassloader$1.run(urlclassloader。java:355)位于java.net.urlclassloader.findclass(urlclassloader)的java.security.accesscontroller.doprivileged(本机方法)。java:354)在java.lang.classloader.loadclass(classloader。java:425)在sun.misc.launcher$appclassloader.loadclass(launcher。java:308)在java.lang.classloader.loadclass(classloader。java:358) ... 3个以上
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
public class test {
public static void main(String[] args) {
try {
PigServer pigServer = new PigServer(ExecType.MAPREDUCE);
runQuery(pigServer);
}catch(Exception e) {
e.printStackTrace();
}
}
public static void runQuery(PigServer pigServer) {
try {
pigServer.registerQuery("input1 = LOAD '/mydata/wct.txt' as (line:chararray);");
pigServer.registerQuery("words = foreach input1 generate FLATTEN(TOKENIZE(line)) as word;");
pigServer.registerQuery("word_groups = group words by word;");
pigServer.registerQuery("word_count = foreach word_groups generate group, COUNT(words);");
pigServer.registerQuery("ordered_word_count = order word_count by group desc;");
pigServer.registerQuery("store ordered_word_count into '/mydata/wct';");
} catch(Exception e) {
e.printStackTrace();
}
}
}
请帮帮我。提前谢谢。
1条答案
按热度按时间laawzig21#
请添加公共依赖项: