Apache Pig,程序运行问题
REGISTER /home/hadoop/pigg/trunk/contrib/piggybank/java/piggybank.jar;
-- Use the PigStorage function to load the excite log file into the raw bag as an array of records.
-- Input: (user,time,query)
A = LOAD 'hadoop-test-data.csv' USING PigStorage(',') AS (user: chararray, site: chararray, view: int, click: int);
B = FOREACH A GENERATE org.apache.pig.piggybank.evaluation.string.UPPER(user);
-- Use the PigStorage function to store the results.
STORE B INTO 'test-pig-result' USING PigStorage();
这是我的代码,我只是将我的用户名转换为大写。我已将此代码存储在 pig 根文件夹中的 test.pig 中。
我正在运行此代码,
java -cp $PIGGDIR/trunk/contrib/piggybank/java/piggybank.jar:$HADOOP_HOME/conf org.apache.pig.piggybank test.pig
但它不断抛出以下错误,
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/pig/piggybank/Main
Caused by: java.lang.ClassNotFoundException: org.apache.pig.piggybank.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.pig.piggybank.Main. Program will exit.
但如果我运行grunt 上的相同程序然后它给我正确的输出。 我已经尝试了 java -cp 的倒数第二个参数的所有可能的参数。
我还需要一个示例,其中使用 CSVLoader 类。
REGISTER /home/hadoop/pigg/trunk/contrib/piggybank/java/piggybank.jar;
-- Use the PigStorage function to load the excite log file into the raw bag as an array of records.
-- Input: (user,time,query)
A = LOAD 'hadoop-test-data.csv' USING PigStorage(',') AS (user: chararray, site: chararray, view: int, click: int);
B = FOREACH A GENERATE org.apache.pig.piggybank.evaluation.string.UPPER(user);
-- Use the PigStorage function to store the results.
STORE B INTO 'test-pig-result' USING PigStorage();
This is my code , i am just converting my username fielded in uppercase.I have stored this code in test.pig in pig root folder.
I am running this code with ,
java -cp $PIGGDIR/trunk/contrib/piggybank/java/piggybank.jar:$HADOOP_HOME/conf org.apache.pig.piggybank test.pig
But its keep throwing following error,
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/pig/piggybank/Main
Caused by: java.lang.ClassNotFoundException: org.apache.pig.piggybank.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.pig.piggybank.Main. Program will exit.
But if I run same program on grunt then it gives me proper output.
I have tried every possible param of java -cp's second last param.
And i also need an example , in which CSVLoader class is used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想在本地运行pig,你应该运行
pig.jar
而不是piggybank.jar
Piggybank.jar 将通过脚本中的 REGISTER 命令包含在脚本中
If you want to run pig locally you should run
pig.jar
notpiggybank.jar
the piggybank.jar will be included in the script by the
REGISTER
command in the script