3

Am trying to add some imports , but when I add import org.apache.spark.streaming.kafka.kafkautils its showing the below error

object kafka is not a member of the object org.apache.spark.streaming.kafka.kafkautils

working on eclipse with scala ide 4.7 version 2.11.11, spark-2.3.0-bin-hadoop2.7 jar files, kafka 2.11 jars, spark-streaming-kafka-0-10_2.11-2.3.0 jar

1 Answer 1

1

If you are using spark-streaming-kafka-0-10_2.11-2.3.0 jar then the KafkaUtils is available in org.apache.spark.streaming.kafka010 this package. So import

import org.apache.spark.streaming.kafka010.KafkaUtils

and not

import org.apache.spark.streaming.kafka.kafkautils 

Hope this hepls!

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you Shankar, that solved my problem , but am getting error at val kafkastream = KafkaUtils.createDirectStream(ssc,"localhost:2181","spark-streaming-consumer-group",Map("mytopic"->5))
near KafkaUtils.createDirectStream its showing error
I tried as per the example. it worked. Thank you so much.
Did not work in Pyspark. Even i used from pyspark.streaming.kafka010 import KafkaUtils

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.