NoClassDefFoundError, cannot run MapReduceColorCount (Avro 1.7.7)

ぐ巨炮叔叔 提交于 2019-12-11 13:34:07

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/25527760/noclassdeffounderror-cannot-run-mapreducecolorcount-avro-1-7-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!