I am trying to run a wordcount job in hadoop. This is the code I am running
public class WordCount {
public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
context.write(word, one);
}
}
}
public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
public void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
context.write(key, new IntWritable(sum));
}
}
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Job job = new Job(conf, "WordCount");
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);\
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.waitForCompletion(true);
job.setJarByClass(WordCount.class);
}
}
This is the command i use to run
jeet@jeet-Vostro-2520:~/Downloads$ hadoop jar wordcount.jar org.gamma.WordCount /user/jeet/getty/gettysburg.txt /user/jeet/getty/out
The error:
at org.apache.hadoop.mapred.Child.main(Child.java:249) Caused by: java.lang.ClassNotFoundException: org.gamma.WordCount$Map 14/01/27 13:16:26 INFO mapred.JobClient: Job complete: job_201401271247_0001 14/01/27 13:16:26 INFO mapred.JobClient: Counters: 7 14/01/27 13:16:26 INFO mapred.JobClient: Job Counters 14/01/27 13:16:26 INFO mapred.JobClient: SLOTS_MILLIS_MAPS=20953 14/01/27 13:16:26 INFO mapred.JobClient: Total time spent by all reduces waiting after reserving slots (ms)=0 14/01/27 13:16:26 INFO mapred.JobClient: Total time spent by all maps waiting after reserving slots (ms)=0 14/01/27 13:16:26 INFO mapred.JobClient: Launched map tasks=4 14/01/27 13:16:26 INFO mapred.JobClient: Data-local map tasks=4 14/01/27 13:16:26 INFO mapred.JobClient: SLOTS_MILLIS_REDUCES=0 14/01/27 13:16:26 INFO mapred.JobClient: Failed map tasks=1
Somebody please help