sparkSession.sparkContext is null with local spark cluster sparkSession.sparkContext is null with local spark cluster elasticsearch elasticsearch

sparkSession.sparkContext is null with local spark cluster


Problem is that SparkContext isn't available in my map function closure. It is available only for driver functions and not for worker tasks.

Spark job is failed due to java.io.NotSerializableException: org.apache.spark.SparkContext