2

I am new to spark, I use the following code to define spark object:

         SparkSession spark = SparkSession
          .builder()
          .appName("Java Spark basic example")
          .config("spark.master", "local")
          .getOrCreate();

I get this exception:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.spark.sql.SQLContext.<init>(Lorg/apache/spark/sql/SparkSession;)V
at org.apache.spark.sql.SparkSession.<init>(SparkSession.scala:159)
at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:957)
at Spark.main(Spark.java:26)

It refers to line 26 where I wrote : .config("spark.master", "local").

Could you please explain why I am getting this error and how to correct it?

Ezz Eddin Othman
  • 163
  • 1
  • 12
  • This would probably mean that you have a mismatch in versions of dependencies. – Mark Rotteveel Apr 28 '19 at 09:00
  • @BenjaminUrquhart the solution in How do I fix a NoSuchMethodError? did not work for me, that's why I created new question. – Ezz Eddin Othman Apr 28 '19 at 13:52
  • @MarkRotteveel, yes you are right I changed my dependencies, and it works now... Please write it as answer so I can mark it correct. And Thanks.... – Ezz Eddin Othman Apr 28 '19 at 13:54
  • I continued working on the code, and I had another problem https://stackoverflow.com/questions/55891658/how-to-fix-this-exception-java-lang-exceptionininitializererror-in-spark I will be very grateful if you can help.... @MarkRotteveel – Ezz Eddin Othman Apr 28 '19 at 19:47

0 Answers0