Class Not Found Exception in Mapreduce wordcount job

前端 未结 9 1285
[愿得一人]
[愿得一人] 2020-12-11 02:03

i am trying to run a wordcount job in hadoop.but always getting a class not found exception.I am posting the class that i wrote and the command i using to run the job

9条回答
  •  -上瘾入骨i
    2020-12-11 02:22

    Though MapReduce program is parallel processing. Mapper, Combiner and Reducer class has sequence flow. Have to wait for completing each flow depends on other class so need job.waitForCompletion(true); But It must to set input and output path before starting Mapper, Combiner and Reducer class. Reference

    Change your code like this:

     public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
    
        Job job = new Job(conf, "WordCount");
    
        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));
    
        job.setJarByClass(WordCount.class);
        job.waitForCompletion(true);
    
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);
    
        job.setMapperClass(Map.class);
        job.setReducerClass(Reduce.class);
    
        job.setInputFormatClass(TextInputFormat.class);
        job.setOutputFormatClass(TextOutputFormat.class);
     }
    

    I hope this will works.

提交回复
热议问题