Exception in thread “streaming-start” java.lang.NoSuchMethodError: org.apache.kafka.clients.consumer.KafkaConsumer.subscribe(Ljava/util/Collection;)V
When I submit the spark application, getting the below error:
Exception in thread "streaming-start" java.lang.NoSuchMethodError:
org.apache.kafka.clients.consumer.KafkaConsumer.subscribe(Ljava/util/Collection;)V
Went through the below URL: http://apache-spark-developers-list.1001551.n3.nabble.com/testing-the-kafka-0-10-connector-td17956.html
Set the below environment variable: SPARK_KAFKA_VERSION=0.10
Added the below dependency:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming-kafka-0-10_2.11</artifactId>
<version>2.1.0.cloudera1</version>
</dependency>
Added the below jar: spark-streaming-kafka-0-10-assembly_2.11.jar
Versions I'm using:
- Spark-2.0.2
- Scala-2.11
- Kafka-0.10
A piece of code:
val CLASS_NAME = this.getClass
val log = org.apache.log4j.LogManager.getLogger(CLASS_NAME)
Your help is highly appreciated.
解决办法:export SPARK_KAFKA_VERSION=0.10
在尝试使用Spark Streaming连接Kafka 0.10时,遇到了java.lang.NoSuchMethodError异常。通过设置SPARK_KAFKA_VERSION环境变量为0.10,并调整依赖配置,最终解决了该问题。

1万+

被折叠的 条评论
为什么被折叠?



