caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrder

18/08/28 22:02:35 ERROR MetricsSystem: Sink class org.apache.spark.metrics.sink.MetricsServlet cannot be instantiated
18/08/28 22:02:35 ERROR SparkContext: Error initializing SparkContext.
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.spark.metrics.MetricsSystem$$anonfun$registerSinks$1.apply(MetricsSystem.scala:200)
	at org.apache.spark.metrics.MetricsSystem$$anonfun$registerSinks$1.apply(MetricsSystem.scala:194)
    at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
	at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
    at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:236)
    at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
    at scala.collection.mutable.HashMap.foreach(HashMap.scala:130)
    at org.apache.spark.metrics.MetricsSystem.registerSinks(MetricsSystem.scala:194)
    at org.apache.spark.metrics.MetricsSystem.start(MetricsSystem.scala:102)
    at org.apache.spark.SparkContext.(SparkContext.scala:513)
    at test.Demo02WordCount$.main(Demo02WordCount.scala:11)
    at test.Demo02WordCount.main(Demo02WordCount.scala)
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
    at com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:537)
    at com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:448)
    at org.apache.spark.metrics.sink.MetricsServlet.(MetricsServlet.scala:48)
    ... 16 more
18/08/28 22:02:35 INFO SparkUI: Stopped Spark web UI at http://192.168.31.27:4040
18/08/28 22:02:35 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
18/08/28 22:02:35 INFO MemoryStore: MemoryStore cleared
18/08/28 22:02:35 INFO BlockManager: BlockManager stopped
18/08/28 22:02:35 INFO BlockManagerMaster: BlockManagerMaster stopped
18/08/28 22:02:35 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
18/08/28 22:02:35 INFO SparkContext: Successfully stopped SparkContext
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.spark.metrics.MetricsSystem$$anonfun$registerSinks$1.apply(MetricsSystem.scala:200)
	at org.apache.spark.metrics.MetricsSystem$$anonfun$registerSinks$1.apply(MetricsSystem.scala:194)
    at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
	at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
    at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:236)
    at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
    at scala.collection.mutable.HashMap.foreach(HashMap.scala:130)
    at org.apache.spark.metrics.MetricsSystem.registerSinks(MetricsSystem.scala:194)
    at org.apache.spark.metrics.MetricsSystem.start(MetricsSystem.scala:102)
    at org.apache.spark.SparkContext.(SparkContext.scala:513)
    at test.Demo02WordCount$.main(Demo02WordCount.scala:11)
    at test.Demo02WordCount.main(Demo02WordCount.scala)
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
    at com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:537)
    at com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:448)
    at org.apache.spark.metrics.sink.MetricsServlet.(MetricsServlet.scala:48)
    ... 16 more
18/08/28 22:02:35 INFO ShutdownHookManager: Shutdown hook called
18/08/28 22:02:35 INFO ShutdownHookManager: Deleting directory /tmp/spark-06673122-4b9e-45d4-851d-2428fe0c41d2

导致此错误的原因是在引入cdh版本的hadoop-client时,导致jackson各lib版本不一致

 <dependency>
    <groupId>org.apache.hadoopgroupId>
    <artifactId>hadoop-clientartifactId>
    <version>2.6.0-cdh5.15.0version>
dependency>

修改如下,因为hadoop-aws依赖较低版本的jackson-core和jackson-annotations

<dependency>
    <groupId>org.apache.hadoopgroupId>
    <artifactId>hadoop-clientartifactId>
    <version>2.6.0-cdh5.15.0version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.hadoopgroupId>
            <artifactId>hadoop-awsartifactId>
        exclusion>
    exclusions>
dependency>

也可以修改jackson各lib版本

你可能感兴趣的:(hadoop学习笔记,scala学习,spark)