Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig, mail # user - pig 0.9.2, embedded pig in python and Script context is not set error


+
agateaaa 2012-11-03, 07:17
Copy link to this message
-
Re: pig 0.9.2, embedded pig in python and Script context is not set error
Cheolsoo Park 2012-11-04, 00:07
Hi,

I am able to reproduce your error. Unfortunately, I don't think that you
can get it working without modifying source code.

The difference between running "pig embed.py" and "java
org.python.util.jython embed.py" is that some initialization happens in the
former while it doesn't in the latter. In particular, ScriptPigContext is
always initialized by Pig before Pig.compile() is called:

ScriptPigContext.set(pigContext, this);

But if the script is executed directly via jython, this step is skipped, so
the exception is thrown:

java.io.IOException: java.io.IOException: Script context is not set

Is there any reason why you run your script directly via jython not via pig?

Thanks,
Cheolsoo
On Sat, Nov 3, 2012 at 12:17 AM, agateaaa <[EMAIL PROTECTED]> wrote:

> Hi
>
> I am using pig 0.9.2. Trying to run embedded pig in python but get this
> error
>
> I have all hadoop lib jars, pig-0.9.2-withouthadoop.jar and
> jython-2.5.2.jar in class path
>
> CLASSPATH> /etc/hadoop
> /usr/lib/jvm/java-6-sun/lib/tools.jar
> /usr/share/hadoop/lib/*.jar
> /etc/pig
> /etc/hadoop
> /usr/share/pig/lib/jython-2.5.2.jar <--replaced this jar with jython-2.5.2
> standalone as per https://issues.apache.org/jira/browse/PIG-2665
> /etc/hadoop
> /usr/share/pig/pig-0.9.2-withouthadoop.jar
>
> java -cp $CLASSPATH org.python.util.jython
> /usr/share/MAB/PaasApp/testembed.py
> Traceback (most recent call last):
>   File "~/testembed.py", line 12, in <module>
>     P = Pig.compileFromFile("""~/testembed.pig""")
>  at org.apache.pig.scripting.Pig.getScriptContext(Pig.java:373)
>  at org.apache.pig.scripting.Pig.compile(Pig.java:158)
>  at org.apache.pig.scripting.Pig.compileFromFile(Pig.java:191)
>  at org.apache.pig.scripting.Pig.compileFromFile(Pig.java:175)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>  at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>  at java.lang.reflect.Method.invoke(Method.java:597)
>
> java.io.IOException: java.io.IOException: Script context is not set
>
> On the other hand running the same script using
>
> pig testembed.py
>
> runs fine
>
> What am I missing?
>
> Thanks in advance
>
> - Agateaaa
>
+
agateaaa 2012-11-04, 01:11