Debugger
Debugger

Reputation: 564

Apache Pig , programe run issue

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.

Upvotes: 0

Views: 634

Answers (1)

Arnon Rotem-Gal-Oz
Arnon Rotem-Gal-Oz

Reputation: 25939

If you want to run pig locally you should run pig.jar not piggybank.jar the piggybank.jar will be included in the script by the REGISTER command in the script

Upvotes: 3

Related Questions