Hello
You are right it's a path issue.
What I was trying to point out is that it was working out of the box before
- in pig 0.5, and now it does not.
You can give it a go with a fresh install, if you remove your 'build' dir,
and just go with 'pig.jar' which is the result of the build script, you get
this nice thing:
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.
I'm a big fan of things working out of the box, and to be completely honest
with you, the first time I've seen this turned me off from the 0.6 thinking
that it's not fully developed yet. I think it was you who suggested me to
try again on twitter ;)
so I did and figured out it's only a script problem, not a pig problem
thanks for your time and attention
alex
On Tue, Feb 9, 2010 at 5:52 PM, Dmitriy Ryaboy <[email protected]> wrote:
> Alex,
> This looks like a path issue. Make sure your classpath includes
> pig.jar . Take a look inside bin/pig -- it's just a bash script,
> pretty easy to follow where it gets its stuff.
>
> -D
>
> On Tue, Feb 9, 2010 at 1:54 AM, Alex Parvulescu
> <[email protected]> wrote:
> > 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
> >
>