When I try to to run the pig
commands in grunt shell it is working. However, when I try to run it with PigRunner
inside a Java program in local mode it is giving found interface but class expected error.
I am using hadoop2.5.0cdh5.3.2
and pig0.12.0
.
I have included the code for the java
file
public class local
{
public static void main(String arg[])
{
try {test();}
catch (IOException e)
{e.printStackTrace();}
}
public static void test() throws IOException
{
File f1 = new File("myscript.pig");
f1.deleteOnExit();
FileWriter fw1 = new FileWriter(f1);
fw1.append("A = load '/home/ritika/NLP/Libraries/dict.txt' as words:chararray;");
fw1.append("dump A;");
fw1.close();
String[] args = { "-x", "local", "myscript.pig" };
PigStats stats = PigRunner.run(args, null);
}
}
This is the error:
2018-12-06 14:54:30,819 [JobControl] ERROR org.apache.hadoop.mapreduce.lib.jobcontrol.JobControl - Error while trying to run jobs. java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.JobContext, but class was expected at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat.setupUdfEnvAndStores(PigOutputFormat.java:225) at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat.checkOutputSpecs(PigOutputFormat.java:186) at org.apache.hadoop.mapreduce.JobSubmitter.checkSpecs(JobSubmitter.java:554) at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:430) at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1295) at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1292) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1642) at org.apache.hadoop.mapreduce.Job.submit(Job.java:1292) at org.apache.hadoop.mapreduce.lib.jobcontrol.ControlledJob.submit(ControlledJob.java:335) at org.apache.hadoop.mapreduce.lib.jobcontrol.JobControl.run(JobControl.java:240) at org.apache.pig.backend.hadoop20.PigJobControl.run(PigJobControl.java:121) at java.lang.Thread.run(Thread.java:748) at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceLauncher$1.run(MapReduceLauncher.java:270)