我在hadoop是新来的。我使用的是猪0.14.0和Hadoop1.2.1。我已经成功地运行猪从咕噜壳和猪批脚本在本地和地图减少模式。现在,我正尝试从Java中的嵌入式猪中运行猪。当我在eclipse中编译我的代码时,我得到以下错误:
org.apache.pig.impl.util.PropertiesUtil.(PropertiesUtil.java:34) at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at org.apache.pig.PigServer.(PigServer.java:202) at test.main(test.java:6)中的线程“java.lang.NoClassDefFoundError: org/apache/java.lang.NoClassDefFoundError/org/LogFactory”中的异常(test.java:6),原因是: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native方法)在java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at 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();
}
}
}
请帮帮我。提前谢谢。
发布于 2016-01-17 17:58:01
请添加公域依赖关系:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
https://stackoverflow.com/questions/29418989
复制