Search code examples
javamavenhadoopavro

NoClassDefFoundError, cannot run MapReduceColorCount (Avro 1.7.7)


When trying to run MapReduceColorCount (new MapReduce API) based on webpage http://avro.apache.org/docs/1.7.7/mr.html, I get the following:

[cloudera@localhost ~]$ hadoop jar avroColorCount.jar exos.MapReduceColorCount2 inavro01 outavro01
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/avro/mapreduce/AvroKeyInputFormat
    at exos.MapReduceColorCount2.run(MapReduceColorCount2.java:71)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
    at exos.MapReduceColorCount2.main(MapReduceColorCount2.java:86)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:212)

For the MRv1 version of the code I get a NoClassDefFoundError for AvroMapper. For other Avro programs I've tested I get the same error for AvroJob.

Do you know the root cause for these kinds of errors ? Note: could not paste my POM file, display was horrible, tried between code quotes but didn't work.


Solution

  • Download the avro-mapred-1.7.1.jar and add it to your classpath.