Sunday, June 26, 2011

java.lang.ClassNotFoundException: WordCount$Map

Today I was trying to run mapreduce wordcount code on my eclipse, I copied code from here http://wiki.apache.org/hadoop/WordCount
but with this I was getting following error,
java.lang.RuntimeException: java.lang.ClassNotFoundException: WordCount$Map

after bit of googling I found
add the commented line below
Job job = new Job(conf, "wordcount");
//job.setJarByClass(WordCount.class);

Now its working :)

11 comments:

  1. I added it and still have this issue .... :\

    ReplyDelete
  2. Replies
    1. This comment has been removed by the author.

      Delete
  3. voila...it works!!!. Not sure why there is no documentation on this in WC pgm.

    ReplyDelete
  4. Thanks after a horrible sunday morning debuging the things finally it worked !!

    ReplyDelete

  5. Job job = new Job(conf, "wordcount");
    job.setJarByClass(WordCount.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);



    Added the above snip and worked for me!
    Thanks

    ReplyDelete
  6. Thanks for your post. For those who say does not work, do not forget to compile your java file again and build your jar again :)

    ReplyDelete
  7. even i tried with job.setJarByClass(PdfInputDriver.class); method but it didn't worked

    MyPdfProject.jar jar exported from eclipse,its working perfect in eclipse.

    Error:-
    java.lang.RuntimeException: java.lang.ClassNotFoundException: WordCountMapperr


    terminal:-

    export LIBJARS=/home/devendar/Desktop/pdf external jars/fontbox-1.3.1.jar,/home/devendar/Desktop/pdf external jars/pdfbox-1.2.0.jar;

    export HADOOP_CLASSPATH=/home/devendar/Desktop/pdfexternaljars/fontbox-1.3.1.jar:/home/devendar/Desktop/pdfexternaljars/pdfbox-1.2.0.jar;

    hadoop jar MyPdfProject.jar -libjars ${LIBJARS} /usr/data/Input/DCPD-201400050.pdf /usr/data/output/outppput



    please help me in solving this issue

    ReplyDelete