使用Cloudera QuickStart VM在Eclipse(Kepler)中运行时,在一个简单的Hadoop程序上看到JsonMappingException

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jackson/map/JsonMappingException
    at org.apache.hadoop.mapreduce.Job$1.run(Job.java:595)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1693)
    at org.apache.hadoop.mapreduce.Job.connect(Job.java:593)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:581)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:612)
    at MaxTemperature.main(MaxTemperature.java:28)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonMappingException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 8 more

正如许多人所建议的那样,尝试从快速启动VM中添加 jackson jar ,但没有成功。

最佳答案

经过几个小时的调试后,通过添加以下jar来找到解决方案:

http://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl/1.9.13
http://mvnrepository.com/artifact/org.codehaus.jackson/jackson-core-asl/1.9.13

希望这可以为初学者节省一些时间,这些初学者可能会在Cloudera quickstart VM上运行hadoop程序(使用eclipse)时遇到类似的问题。

08-26 20:56