I am trying to use ChainMapper/ChainReducer of hadoop-mapreduce lib.
For compiling I use,
javac -Xlint -cp /opt/cloudera/parcels/CDH-4.3.0-1.cdh4.3.0.p0.22/lib/hadoop-
mapreduce/*:`hadoop classpath` -d classes *.java
I have to separately include /opt/cloudera/parcels/CDH-4.3.0-1.cdh4.3.0.p0.22/lib/hadoop-mapreduce/*
because the compiler complains otherwise. (Its not included in hadoop classpath
)
It compiles fine when I run the jar it says,
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/lib/chain/ChainMapper
at job_name.main(job_name.java:72)
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)
at org.apache.hadoop.util.RunJar.main(RunJar.java:208)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapreduce.lib.chain.ChainMapper
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 java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 6 more
My Driver class is as follows,
Configuration conf = new Configuration(false);
FileSystem fs = FileSystem.get(conf);
Job job = new Job(conf,"job_name");
job.setJarByClass(SetUpJob.class);
FileInputFormat.setInputPaths(job, new Path(args[1]));
FileOutputFormat.setOutputPath(job, new Path(args[2]));
ChainMapper.addMapper(job,Mapper1.class,LongWritable.class,Text.class,Text.class,IntWritable.class,conf);
ChainReducer.setReducer(job,myReducer.class,LongWritable.class,Text.class,BytesWritable.class,IntWritable.class,conf);
ChainReducer.addMapper(job,Mapper2.class,LongWritable.class,Text.class,Text.class,IntWritable.class,conf);
ChainReducer.setReducer(job,myReducer.class,LongWritable.class,Text.class,BytesWritable.class,IntWritable.class,conf);
ChainReducer.addMapper(job,Mapper3.class,LongWritable.class,Text.class,Text.class,IntWritable.class,conf);
ChainReducer.setReducer(job,myReducer.class,LongWritable.class,Text.class,BytesWritable.class,IntWritable.class,conf);
job.setOutputFormatClass(TextOutputFormat.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(IntWritable.class);
job.setOutputKeyClass(BytesWritable.class);
job.setOutputValueClass(Text.class);
System.exit(job.waitForCompletion(true) ? 0 : 1);
I run the jar as hadoop jar jar_name.jar job_name <parameters>
Is my runtime environment not able to find the class? How do I set this right?