AnsweredAssumed Answered

Q:spark kafka streaming Error - Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/streaming/kafka/v09/KafkaUtils$

Question asked by sohan on Jun 26, 2017
Latest reply on Jun 28, 2017 by vmeghraj

I am writing a simple spark streaming code in eclipse to consume the messages from MapR-streams using spark streaming. Below are the dependencies I used. 

 

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Credit_Fraud</groupId>
<artifactId>Credit_Fraud</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>

<resources>
<resource>
<directory>src/main/scala</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository> <id>mapr-releases</id>
<url>http://repository.mapr.com/maven/</url>
<snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>

</repositories>

<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.6.1-mapr-1607</version>
</dependency>

<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming-kafka-v09_2.10</artifactId>
<version>1.6.1-mapr-1607</version>
</dependency>

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.9.0.0-mapr-1602-streams-5.1.0</version>
</dependency>


<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.10</artifactId>
<version>1.6.1-mapr-1607</version>
</dependency>

<!-- <dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming-kafka-producer_2.10</artifactId>
<version>1.6.1-mapr-1607</version>

</dependency> -->
</dependencies>
</project>

 

 

 

Here is the exception I am getting:   

 

 

17/06/26 12:18:57 INFO BlockManager: Initialized BlockManager: BlockManagerId(driver, 172.21.8.101, 34589, None)
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/streaming/kafka/v09/KafkaUtils$
at com.ventois.credit.fraud.stream$.main(stream.scala:27)
at com.ventois.credit.fraud.stream.main(stream.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.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:743)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.streaming.kafka.v09.KafkaUtils$
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
17/06/26 12:18:58 INFO SparkContext: Invoking stop() from shutdown hook
17/06/26 12:18:58 INFO SparkUI: Stopped Spark web UI at http://172.21.8.101:4041
17/06/26 12:18:58 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
17/06/26 12:18:58 INFO MemoryStore: MemoryStore cleared
17/06/26 12:18:58 INFO BlockManager: BlockManager stopped
17/06/26 12:18:58 INFO BlockManagerMaster: BlockManagerMaster stopped
17/06/26 12:18:58 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
17/06/26 12:18:58 INFO SparkContext: Successfully stopped SparkContext
17/06/26 12:18:58 INFO ShutdownHookManager: Shutdown hook called
17/06/26 12:18:58 INFO ShutdownHookManager: Deleting directory /tmp/spark-95b5df27-a337-400b-9938-0f3c65353723
[root@mapr1 ~]#

 

 

Please help us to get out of it . 

Outcomes