• 在CDH集群外提交Spark流处理程序报错NoClassDefFoundError kafka consumer


    如题,详细报错信息如下:

    20/03/05 11:20:06 ERROR ApplicationMaster: User class threw exception: java.lang.NoClassDefFoundError: org/apache/kafka/clients/consumer/Consumer
    java.lang.NoClassDefFoundError: org/apache/kafka/clients/consumer/Consumer
        at org.apache.spark.streaming.kafka010.ConsumerStrategies$.Subscribe(ConsumerStrategy.scala:256)
        at com.znv.facecluster.utils.SparkUtils$.getStreamFormKafka(SparkUtils.scala:40)
        at com.znv.facecluster.topic.FaceClusterTopic$.readPicture(FaceClusterTopic.scala:37)
        at com.znv.facecluster.topic.FaceClusterTopic$.process(FaceClusterTopic.scala:28)
        at com.znv.facecluster.entry.RealTimeFaceClusterApp$.main(RealTimeFaceClusterApp.scala:76)
        at com.znv.facecluster.entry.RealTimeFaceClusterApp.main(RealTimeFaceClusterApp.scala)
        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 org.apache.spark.deploy.yarn.ApplicationMaster$$anon$4.run(ApplicationMaster.scala:721)
    Caused by: java.lang.ClassNotFoundException: org.apache.kafka.clients.consumer.Consumer
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 11 more

    经测试,在集群服务器上提交是可以正常运行的,但是在集群外提交就报这个与Kafka相关的错误。

    从错误日志看,是找不到Kafka Consumer这个类,但是在集群中提交是正常的,说明在集群中提交程序,spark可能把Kafka Client的jar包也上传了(仅是猜测,待考证),既然如此在集群外提交时把kafka client的jar包一同上传不久ok了,说干就干。把 kafka-clients-0.10.0.1.jar在spark-submit的--jars中增加上,提交运行,结果不如所料,问题被解决了。

  • 相关阅读:
    The builder launch configuration could not be found
    桌面上的图标不见了
    outlook软件后台运行
    c盘突然少了容量
    win7台式机睡眠时间修改
    系统占用的内存
    详细讲解 java 中的synchronized 转自 http://www.cnblogs.com/devinzhang/archive/2011/12/14/2287675.html
    The US ASCII Character Set 对应码 可以解决 URL中的特殊符号的传输问题
    oracle基本操作 转载
    内存中的 栈与堆
  • 原文地址:https://www.cnblogs.com/144823836yj/p/12421098.html
Copyright © 2020-2023  润新知