java.lang.NoSuchMethodError:org.apache.spark.ui.SparkUI.addStaticHandler(Ljava / lang / String; Ljava / lang / String;

时间:2015-11-06 13:34:06

标签: java apache-spark

我正在运行以下关于Java + Spark + SQL的示例。

https://github.com/apache/spark/blob/master/examples/src/main/java/org/apache/spark/examples/sql/JavaSparkSQL.java

但得到这个例外。编译时没有错误

我怎能避免这个? 无法找到有关此例外的任何内容。 请帮助我。

SparkConf sparkConf = new SparkConf().setMaster("local").setAppName("JavaSparkSQL");
JavaSparkContext ctx = new JavaSparkContext(sparkConf);
SQLContext sqlContext = new SQLContext(ctx);

异常追踪:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.spark.ui.SparkUI.addStaticHandler(Ljava/lang/String;Ljava/lang/String;)V
    at org.apache.spark.sql.execution.ui.SQLTab.<init>(SQLTab.scala:36)
    at org.apache.spark.sql.SQLContext$$anonfun$1.apply(SQLContext.scala:79)
    at org.apache.spark.sql.SQLContext$$anonfun$1.apply(SQLContext.scala:79)
    at scala.Option.foreach(Option.scala:257)
    at org.apache.spark.sql.SQLContext.<init>(SQLContext.scala:79)
    at org.apache.spark.sql.SQLContext.<init>(SQLContext.scala:69)
    at org.sun.JavaSparkSQL.main(JavaSparkSQL.java:47)
2015-11-06 18:35:22,834 INFO  org.apache.spark.SparkContext.logInfo:59 - Invoking stop() from shutdown hook

pom.xml依赖项

 <dependency>
     <groupId>org.apache.spark</groupId>
     <artifactId>spark-sql_2.11</artifactId>
     <version>1.5.1</version>
 </dependency>
 <dependency>
     <groupId>org.apache.spark</groupId>
     <artifactId>spark-core_2.11</artifactId>
     <version>1.4.0</version>
 </dependency>

1 个答案:

答案 0 :(得分:5)

这是一个版本问题!您应该始终使用所有依赖项的相同版本。