Spark Kafka Streaming Issue

mithra

I am using maven

i have added the following dependencies

   <dependency> <!-- Spark dependency -->
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-streaming_2.10</artifactId>
      <version>1.1.0</version>
    </dependency>   <dependency> <!-- Spark dependency -->
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-streaming-kafka_2.10</artifactId>
      <version>1.1.0</version>
    </dependency>

I have also added the jar in the code

SparkConf sparkConf = new SparkConf().setAppName("KafkaSparkTest");
JavaSparkContext sc = new JavaSparkContext(sparkConf);
sc.addJar("/home/test/.m2/repository/org/apache/spark/spark-streaming-kafka_2.10/1.0.2/spark-streaming-kafka_2.10-1.0.2.jar");
JavaStreamingContext jssc = new JavaStreamingContext(sc, new Duration(5000)); 

It comples fine with out any error , i am getting the following error when i run through spark-submit, any help is much appreciated. Thanks for your time.

bin/spark-submit --class "KafkaSparkStreaming" --master local[4] try/simple-project/target/simple-project-1.0.jar

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/streaming/kafka/KafkaUtils at KafkaSparkStreaming.sparkStreamingTest(KafkaSparkStreaming.java:40) at KafkaSparkStreaming.main(KafkaSparkStreaming.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.spark.deploy.SparkSubmit$.launch(SparkSubmit.scala:303) at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:55) at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala) Caused by: java.lang.ClassNotFoundException: org.apache.spark.streaming.kafka.KafkaUtils at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

secfree

I meet the same problem, I solved it by build the jar with dependencies.

  1. remove "sc.addJar()" in your code.

  2. add the code below to pom.xml

    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <plugins>
          <!--
                       Bind the maven-assembly-plugin to the package phase
            this will create a jar file without the storm dependencies
            suitable for deployment to a cluster.
           -->
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
              <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>
              <archive>
                <manifest>
                  <mainClass></mainClass>
                </manifest>
              </archive>
            </configuration>
            <executions>
              <execution>
                <id>make-assembly</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
    </build>    
    
  3. mvn package

  4. submit the "example-jar-with-dependencies.jar"

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

ExceptionInInitializerError Spark Streaming Kafka

分類Dev

Kafka topic partitions to Spark streaming

分類Dev

Spark Structured Streaming with Kafka version 2

分類Dev

Spark Streaming + Kafka統合0.8.2.1

分類Dev

Spark 1.6 Streaming consumer reading in kafka offset stuck at createDirectStream

分類Dev

How to read from specific Kafka partition in Spark structured streaming

分類Dev

Spark Streaming Kafka java.lang.ClassNotFoundException:org.apache.kafka.common.serialization.StringDeserializer

分類Dev

spark-streaming-kafka-0-10 auto.offset.reset is always set to none

分類Dev

Kafka + Spark Streaming-パーティション間の公平性?

分類Dev

How to fix "java.io.NotSerializableException: org.apache.kafka.clients.consumer.ConsumerRecord" in Spark Streaming Kafka Consumer?

分類Dev

spark streaming throughput monitoring

分類Dev

Spark Streaming textFileStream COPYING

分類Dev

Dstream Spark Streaming

分類Dev

spark-streaming-kafka-0-10auto.offset.resetは常にnoneに設定されます

分類Dev

Kafka Spark Streaming LocationStrategiesjavaクラス定義が見つかりません例外

分類Dev

Apache Kafka streaming KTable changelog

分類Dev

Understanding Spark Structured Streaming Parallelism

分類Dev

Spark Streaming standalone app and dependencies

分類Dev

Parallelism of Streams in Spark Streaming Context

分類Dev

Spark Streamingで最初からKafkaトピックのレコードを読み取る方法は?

分類Dev

SparkStreaming&Kafka:値reduceByKeyはorg.apache.spark.streaming.dstream.DStream [Any]のメンバーではありません

分類Dev

Spark Structed Streamingは、kafkaからネストされたjsonを読み取り、フラット化します

分類Dev

Sparkkafkaストリーミングエラー-"java.lang.NoClassDefFoundError:org / apache / spark / streaming / kafka / KafkaUtils

分類Dev

kafkaでspark-streamingジョブを実行すると、NoSuchMethodErrorが発生します

分類Dev

Spark Arrow Streaming = Arrow Streaming + Spark Structured Streamingはありますか?

分類Dev

Spark performance issue at NOT IN query

分類Dev

spark reduce and map issue

分類Dev

spark-streaming: how to output streaming data to cassandra

分類Dev

Spark Streaming Kafka Consumerで「java.io.NotSerializableException:org.apache.kafka.clients.consumer.ConsumerRecord」を修正するにはどうすればよいですか?

Related 関連記事

  1. 1

    ExceptionInInitializerError Spark Streaming Kafka

  2. 2

    Kafka topic partitions to Spark streaming

  3. 3

    Spark Structured Streaming with Kafka version 2

  4. 4

    Spark Streaming + Kafka統合0.8.2.1

  5. 5

    Spark 1.6 Streaming consumer reading in kafka offset stuck at createDirectStream

  6. 6

    How to read from specific Kafka partition in Spark structured streaming

  7. 7

    Spark Streaming Kafka java.lang.ClassNotFoundException:org.apache.kafka.common.serialization.StringDeserializer

  8. 8

    spark-streaming-kafka-0-10 auto.offset.reset is always set to none

  9. 9

    Kafka + Spark Streaming-パーティション間の公平性?

  10. 10

    How to fix "java.io.NotSerializableException: org.apache.kafka.clients.consumer.ConsumerRecord" in Spark Streaming Kafka Consumer?

  11. 11

    spark streaming throughput monitoring

  12. 12

    Spark Streaming textFileStream COPYING

  13. 13

    Dstream Spark Streaming

  14. 14

    spark-streaming-kafka-0-10auto.offset.resetは常にnoneに設定されます

  15. 15

    Kafka Spark Streaming LocationStrategiesjavaクラス定義が見つかりません例外

  16. 16

    Apache Kafka streaming KTable changelog

  17. 17

    Understanding Spark Structured Streaming Parallelism

  18. 18

    Spark Streaming standalone app and dependencies

  19. 19

    Parallelism of Streams in Spark Streaming Context

  20. 20

    Spark Streamingで最初からKafkaトピックのレコードを読み取る方法は?

  21. 21

    SparkStreaming&Kafka:値reduceByKeyはorg.apache.spark.streaming.dstream.DStream [Any]のメンバーではありません

  22. 22

    Spark Structed Streamingは、kafkaからネストされたjsonを読み取り、フラット化します

  23. 23

    Sparkkafkaストリーミングエラー-"java.lang.NoClassDefFoundError:org / apache / spark / streaming / kafka / KafkaUtils

  24. 24

    kafkaでspark-streamingジョブを実行すると、NoSuchMethodErrorが発生します

  25. 25

    Spark Arrow Streaming = Arrow Streaming + Spark Structured Streamingはありますか?

  26. 26

    Spark performance issue at NOT IN query

  27. 27

    spark reduce and map issue

  28. 28

    spark-streaming: how to output streaming data to cassandra

  29. 29

    Spark Streaming Kafka Consumerで「java.io.NotSerializableException:org.apache.kafka.clients.consumer.ConsumerRecord」を修正するにはどうすればよいですか?

ホットタグ

アーカイブ