Spark 啟動java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/Module 報錯
阿新 • • 發佈:2019-02-06
之前一直沒有搞過Spark,這陣有時間,今天在搭建的過程中在啟動Spark的時候發現了報錯,之前以為是不是有什麼配置自己沒有搞清楚,最後搜尋半天還是沒有找到,自己試著找了一下包,Ok成功啟動,在這裡記下,避免其他人在這塊費時間
下面是異常資訊,很明顯是缺少類,之前一直以為是自己沒有配置清楚,沒有想到是缺包,博主的是在裝的偽分佈版本如下
hadoop-2.6.0-cdh5.12.1.tar.gz
spark-1.6.0-cdh5.12.1.tar.gz
因為都是CDH對應的版本,壓根就沒想到是Jar包的問題
異常:
Exception in thread dispatcher-event-loop-1
java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/Module
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.spark.util.Utils$.classForName(Utils.scala:177)
at org.apache.spark.metrics.MetricsSystem$$anonfun$registerSinks$1.apply (MetricsSystem.scala:196)
at org.apache.spark.metrics.MetricsSystem$$anonfun$registerSinks$1.apply(MetricsSystem.scala:192)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:98)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:98)
at scala.collection .mutable.HashTable$class.foreachEntry(HashTable.scala:226)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:39)
at scala.collection.mutable.HashMap.foreach(HashMap.scala:98)
at org.apache.spark.metrics.MetricsSystem.registerSinks(MetricsSystem.scala:192)
at org.apache.spark.metrics.MetricsSystem.start(MetricsSystem.scala:100)
at org.apache.spark.deploy.master.Master.onStart(Master.scala:160)
at org.apache.spark.rpc.netty.Inbox$$anonfun$process$1.apply$mcV$sp(Inbox.scala:121)
at org.apache.spark.rpc.netty.Inbox.safelyCall(Inbox.scala:204)
at org.apache.spark.rpc.netty.Inbox.process(Inbox.scala:100)
at org.apache.spark.rpc.netty.Dispatcher$MessageLoop.run(Dispatcher.scala:217)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.Module
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 20 more
解決方案 用Maven下載下面的三個包,放到Spark的類載入路徑下就可以了
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.4</version>
</dependency>