2017-02-25 85 views
0

我試圖寫一個簡單的代碼,用於訪問使用SparkSql蜂巢表:Spark-Hive錯誤,我該如何解決?

SparkSession spark = SparkSession.builder() 
           .appName("Java Spark Hive Example") 
           .master("local[*]") 
           .config("hive.metastore.uris", "thrift://localhost:9083") 
           .enableHiveSupport() 
           .getOrCreate(); 

try{ 
    Dataset<Row> df = spark.sql("select survey_response_value from health"); 
    df.show(); 
} catch (Exception AnalysisException) { 
    System.out.print("\nTable is not found\n"); 
} 

我跑我的系統多次在這個特定的程序,它運行良好。但突然間它停止工作並開始犯錯。
以下是錯誤和跟蹤的完整列表:
https://justpaste.it/13w2r
我正在使用IntelliJ。

我還沒有做任何與依賴關係或與代碼。所以我不明白是什麼讓代碼不起作用。我怎樣才能擺脫它?請幫助我。 這裏的問題是:

17:22:50.442 [main] INFO org.apache.spark.SparkContext - Created broadcast 0 from show at hivespark.java:29 
Exception in thread "main" java.lang.ExceptionInInitializerError 
    at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:132) 
    at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:113) 
    at org.apache.spark.sql.execution.SparkPlan.getByteArrayRdd(SparkPlan.scala:225) 
    at org.apache.spark.sql.execution.SparkPlan.executeTake(SparkPlan.scala:308) 
    at org.apache.spark.sql.execution.CollectLimitExec.executeCollect(limit.scala:38) 
    at org.apache.spark.sql.Dataset$$anonfun$org$apache$spark$sql$Dataset$$execute$1$1.apply(Dataset.scala:2371) 
    at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:57) 
    at org.apache.spark.sql.Dataset.withNewExecutionId(Dataset.scala:2765) 
    at org.apache.spark.sql.Dataset.org$apache$spark$sql$Dataset$$execute$1(Dataset.scala:2370) 
    at org.apache.spark.sql.Dataset.org$apache$spark$sql$Dataset$$collect(Dataset.scala:2377) 
    at org.apache.spark.sql.Dataset$$anonfun$head$1.apply(Dataset.scala:2113) 
    at org.apache.spark.sql.Dataset$$anonfun$head$1.apply(Dataset.scala:2112) 
    at org.apache.spark.sql.Dataset.withTypedCallback(Dataset.scala:2795) 
    at org.apache.spark.sql.Dataset.head(Dataset.scala:2112) 
    at org.apache.spark.sql.Dataset.take(Dataset.scala:2327) 
    at org.apache.spark.sql.Dataset.showString(Dataset.scala:248) 
    at org.apache.spark.sql.Dataset.show(Dataset.scala:636) 
    at org.apache.spark.sql.Dataset.show(Dataset.scala:595) 
    at org.apache.spark.sql.Dataset.show(Dataset.scala:604) 
    at sparky.hivespark.main(hivespark.java:29) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) 
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Jackson version is too old 2.5.1 
    at com.fasterxml.jackson.module.scala.JacksonModule$class.setupModule(JacksonModule.scala:56) 
    at com.fasterxml.jackson.module.scala.DefaultScalaModule.setupModule(DefaultScalaModule.scala:19) 
    at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:651) 
    at org.apache.spark.rdd.RDDOperationScope$.<init>(RDDOperationScope.scala:82) 
    at org.apache.spark.rdd.RDDOperationScope$.<clinit>(RDDOperationScope.scala) 
    ... 25 more 
17:22:50.612 [Thread-2] INFO org.apache.spark.SparkContext - Invoking stop() from shutdown hook 
+0

能喲你把構建文件與範圍,具體更快-xml依賴 – FaigB

回答

1

如果你正在使用SBT再加入....

這裏我提到2.8.x你也可以提任何版本,其中2.5以上

是在您的環境兼容
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core 
libraryDependencies += "com.fasterxml.jackson.core" % "jackson-core" % "2.8.7" 

// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind 
libraryDependencies += "com.fasterxml.jackson.core" % "jackson-databind" % "2.8.7" 

如果你使用maven

<dependency> 
    <groupId>com.fasterxml.jackson.core</groupId> 
    <artifactId>jackson-core</artifactId> 
    <version>2.8.7</version> 
</dependency> 



<dependency> 
    <groupId>com.fasterxml.jackson.core</groupId> 
    <artifactId>jackson-databind</artifactId> 
    <version>2.8.7</version> 
</dependency> 
+0

是否還有什麼你在這之後面臨?請回復。 –