Hello,
I have a problem starting the grunt shell. I think this affects the 0.6
branch and forward.
This is the error I get when I try to start the shell or when I try to run
any script:
a...@alex-desktop:~/hadoop/pig/bin$ pig
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/pig/Main
Caused by: java.lang.ClassNotFoundException: org.apache.pig.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: org.apache.pig.Main. Program will exit.
A variation of this is also:
a...@alex-desktop:~/hadoop/pig/bin$ pig
Exception in thread "main" java.lang.NoClassDefFoundError:
jline/ConsoleReaderInputStream
Caused by: java.lang.ClassNotFoundException: jline.ConsoleReaderInputStream
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: org.apache.pig.Main. Program will exit.
I poked around a bit and I think the 'bin/pig' script does not build the
classpath correctly
Option #1
I you use only the pig.jar file that gets generated from the build
PIG_HOME/pig.jar you get java.lang.ClassNotFoundException the second error.
This is only if you don't have the 'build' directory in place.
This happened to me while I was trying to move the pig dir from local to a
test server. I was trying to cut down on the size.
Case #2
Let's say that you have the pig.jar and the build directory generated by the
build. Now you get java.lang.NoClassDefFoundError:
jline/ConsoleReaderInputStream
Now my pig install looks like this:
pig/pig.jar
/pig/build/pig-0.6.0-dev.jar
pig/build/pig-0.6.0-dev-core.jar
...
As far as I can see this happens also if you try to copy the dev jars into
the main directory( replacing the pig.jar):
pig/pig-0.6.0-dev.jar
pig/pig-0.6.0-dev-core.jar
I think the problem comes from the pig script that builds the classpath:
pig/bin/pig :
.......
# for releases, add core pig to CLASSPATH
for f in $PIG_HOME/pig-*-core.jar; do
CLASSPATH=${CLASSPATH}:$f;
done
# during development pig jar might be in build
for f in $PIG_HOME/build/pig-*-core.jar; do
CLASSPATH=${CLASSPATH}:$f;
done
......
As you can see none of this matches the 'light' version
(pig-0.6.0-dev-core.jar) that does not include everything, instead this
should match (pig-0.6.0-dev.jar).
This appears to be a change from the pig 0.5 release which works for me ok,
and is packing pig-0.5.0-core.jar as the full dependencies version, whereas
the pig-0.6.0-dev-core.jar is the light version.
Also this problem goes away if you just rename pig-0.6.0-dev.jar to
pig-0.6.0-dev-core.jar, so you can have a fully functioning console.
I hope this helps anybody
alex