title: Spark - Error “A master URL must be set in your configuration” using Intellij IDEA
body: <p>When i am trying to hit the Spark streaming application using Intellij IDEA</p>
  
  <p><strong>Env</strong> </p>
  
  <p>Spark core version 2.2.0
  Intellij IDEA 2017.3.5 VERSION </p>
  
  <p>Additional info :
  Spark is running on Yarn mode.</p>
  
  <p><strong>Getting Error :</strong></p>
  
  <pre><code>Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
  Exception in thread "main" java.lang.ExceptionInInitializerError
      at kafka_stream.kafka_stream.main(kafka_stream.scala)
  Caused by: org.apache.spark.SparkException: A master URL must be set in your configuration
      at org.apache.spark.SparkContext.&lt;init&gt;(SparkContext.scala:376)
      at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2509)
      at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:909)
      at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:901)
      at scala.Option.getOrElse(Option.scala:121)
      at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:901)
      at kafka_stream.InitSpark$class.$init$(InitSpark.scala:15)
      at kafka_stream.kafka_stream$.&lt;init&gt;(kafka_stream.scala:6)
      at kafka_stream.kafka_stream$.&lt;clinit&gt;(kafka_stream.scala)
      ... 1 more
  
  Process finished with exit code 1
  </code></pre>
  
  <p><strong>Tried this</strong> </p>
  
  <pre><code>  val spark: SparkSession = SparkSession.builder()
      .appName("SparkStructStream")
      .master("spark://127.0.0.1:7077")
      //.master("local[*]")
      .getOrCreate()
  </code></pre>
  
  <p>Still getting the same MASTER URL ERROR</p>
  
  <p>Content of  build.sbt file </p>
  
  <pre><code>name := "KafkaSpark"
  
  version := "1.0"
  
  scalaVersion := "2.11.8"
  
  libraryDependencies ++= Seq(
    "org.apache.spark" % "spark-core_2.11" % "2.2.0",
    "org.apache.spark" % "spark-sql_2.11" % "2.2.0",
    "org.apache.spark" % "spark-streaming_2.11" % "2.2.0",
    "org.apache.spark" % "spark-streaming-kafka_2.11" % "1.6.3"
  )
  
  // https://mvnrepository.com/artifact/org.apache.kafka/kafka_2.11
  libraryDependencies += "org.apache.kafka" % "kafka_2.11" % "0.11.0.0"
  
  // https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients
  libraryDependencies += "org.apache.kafka" % "kafka-clients" % "0.11.0.0"
  
  // https://mvnrepository.com/artifact/org.apache.kafka/kafka-streams
  libraryDependencies += "org.apache.kafka" % "kafka-streams" % "0.11.0.0"
  
  // https://mvnrepository.com/artifact/org.apache.kafka/connect-api
  libraryDependencies += "org.apache.kafka" % "connect-api" % "0.11.0.0"
  
  libraryDependencies += "com.databricks" %% "spark-avro" % "4.0.0"
  
  resolvers += Resolver.mavenLocal
  resolvers += "central maven" at "https://repo1.maven.org/maven2/"
  </code></pre>
  
  <p>Any help on it would be much appreciated ?</p>