Lets try to identify and fix the issue as regards to a common Spark error. Typically Spark application runs fine is Local Mode . But when submitted to the Spark cluster sometimes it errors out with below message -
org.apache.spark.SparkException: A master URL must be set in your configuration
spark-submit --class ExmpleApp --master spark://cluster-node1-appnn1:7077 --jars $apppath app.jar
You might try the below fix -
SparkSession spark = SparkSession
.builder()
.appName("Basic App")
.config("spark.master", "local")
.getOrCreate();