guzu92
guzu92

Reputation: 737

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.

Upvotes: 1

Views: 1780

Answers (2)

shifu.zheng
shifu.zheng

Reputation: 711

If you are using maven to build your jar, you need to add the following dependency:

    <dependency>
        <groupId>org.apache.avro</groupId>
        <artifactId>avro</artifactId>
    </dependency>

And make a fat jar to run it in command console.

Upvotes: 0

Jens
Jens

Reputation: 69440

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

Upvotes: 1

Related Questions