Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark 为什么我的Spark应用程序无法使用“运行”;NoSuchMethodException:org.apache.spark.util.SystemClock“是什么;?_Apache Spark_Apache Kafka_Spark Streaming - Fatal编程技术网

Apache spark 为什么我的Spark应用程序无法使用“运行”;NoSuchMethodException:org.apache.spark.util.SystemClock“是什么;?

Apache spark 为什么我的Spark应用程序无法使用“运行”;NoSuchMethodException:org.apache.spark.util.SystemClock“是什么;?,apache-spark,apache-kafka,spark-streaming,Apache Spark,Apache Kafka,Spark Streaming,我正在尝试使用JavaAPI而不是scala从apache Spark流媒体连接到Kafka 我遇到以下错误: 原因:java.lang.NoSuchMethodException: org.apache.spark.util.SystemClock.() getConstructor0(Class.java:3082)位于 java.lang.Class.newInstance(Class.java:412) 创建JavaStreamingContext对象时出现错误 这是我的代码: Java

我正在尝试使用JavaAPI而不是scala从apache Spark流媒体连接到Kafka

我遇到以下错误:

原因:java.lang.NoSuchMethodException: org.apache.spark.util.SystemClock.() getConstructor0(Class.java:3082)位于 java.lang.Class.newInstance(Class.java:412)

创建JavaStreamingContext对象时出现错误

这是我的代码:

JavaStreamingContext jssc = new JavaStreamingContext("local[2]", "KafkaWordCount",
            new Duration(2000), System.getenv("SPARK_HOME"),
            JavaStreamingContext.jarOfClass(JavaKafkaWordCount.class));

    Map<String, Integer> topicMap = new HashMap<String, Integer>();

    topicMap.put("fast-messages", 2);

    JavaPairDStream<String, String> messages = KafkaUtils.createStream(jssc, "localhost:9092", "test", topicMap);

    JavaDStream<String> lines = messages.map(new Function<Tuple2<String, String>, String>() {
     // @Override
      public String call(Tuple2<String, String> tuple2) {
        return tuple2._2();
      }
    });
JavaStreamingContext jssc=newjavastreamingcontext(“local[2]”,“KafkaWordCount”,
新期限(2000年),System.getenv(“SPARK_HOME”),
JavaStreamingContext.jarOfClass(JavaKafkaWordCount.class));
Map topicMap=newhashmap();
topicMap.put(“快速消息”,2);
JavaPairDStream messages=KafkaUtils.createStream(jssc,“localhost:9092”,“test”,topicMap);
JavadStreamLines=messages.map(新函数(){
//@覆盖
公共字符串调用(Tuple2 Tuple2){
返回tuple2._2();
}
});
Jar版本:

spark-streaming-kafka_2.10-1.6.2 spark-core_2.11-1.2.1 spark-streaming_2.10-1.6.0


如果您需要更多信息,请告诉我。

TL;DR使用
spark-core_2.10

这是因为使用中的Scala版本的依赖项不匹配

参见
spark-streaming-kafka_2.10
spark-core_2.11
spark-streaming_2.10
。流JAR是为Scala 2.10编译的,而spark core是为2.11编译的

它不会强迫您在Java上使用Scala。Spark主要使用Scala编写,使用Scala构建的依赖项必须与其Scala版本相匹配