Spark fails with NoClassDefFoundError for org.apache.kafka.common.serialization.StringDeserializer

后端 未结 2 1635
死守一世寂寞
死守一世寂寞 2021-01-16 13:38

I am developing a generic Spark application that listens to a Kafka stream using Spark and Java.

I am using kafka_2.11-0.10.2.2, spark-2.3.2-bin-hadoop2.7 - I also t

2条回答
  •  醉酒成梦
    2021-01-16 14:16

    You need to use the Maven Shade Plugin to package the Kafka clients along with your Spark application, then you can submit the shaded Jar, and the Kafka serializers should be found on the classpath.

    Also, make sure you set the provided Spark packages

    
        org.apache.spark
        spark-core_${spark.scala.version}
        ${spark.version}
        provided
    
    
        org.apache.spark
        spark-streaming_${spark.scala.version}
        ${spark.version}
        provided
    
    

提交回复
热议问题