title: Why ExceptionInInitializerError when submitting Spark application in YARN cluster mode?
body: <p>I am using spark "Spark 1.6.1-mapr-1604 " version. <br>My job in local mode executes successfully but when I launch same job in yarn cluster mode it throws <code>ExceptionInInitializerError</code>.</p>
  
  <p><strong>Local mode command:</strong> <br></p>
  
  <pre><code>spark-submit --class com.ts.clustering.TrainModel \
  ts-0.0.1-SNAPSHOT.jar \
  -model /user/hive/warehouse/ts/clustering_model 
  -ip /user/hive/warehouse/ts/aidata_seq/* 
  -k 10 -ite 10 &gt; app_2.log &amp;
  </code></pre>
  
  <p><strong>Yarn cluster mode:</strong></p>
  
  <pre><code>spark-submit --queue dev --master yarn \
  --deploy-mode cluster \
  --class com.ts.clustering.TrainModel ts-0.0.1-SNAPSHOT.jar \
  -model /user/hive/warehouse/ts/clustering_model \
  -ip /user/hive/warehouse/ts/aidata_seq/* -k 10 -ite 10 &gt; app_2.log &amp;
  </code></pre>
  
  <p><code>-model</code> parameter is the output location for model to be saved. </p>
  
  <p>The exception in cluster mode:</p>
  
  <pre><code>2016-08-29 17:18:46,312 WARN  [task-result-getter-0] scheduler.TaskSetManager: 
    Lost task 0.0 in stage 0.0 (TID 0, ******************): java.lang.ExceptionInInitializerError
          at com.ts.clustering.TrainModel$2.call(TrainModel.java:71)
          at com.ts.clustering.TrainModel$2.call(TrainModel.java:67)
          at org.apache.spark.api.java.JavaPairRDD$$anonfun$toScalaFunction$1.apply(JavaPairRDD.scala:1015)
          at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
          at scala.collection.Iterator$$anon$14.hasNext(Iterator.scala:389)
          at org.apache.spark.storage.MemoryStore.unrollSafely(MemoryStore.scala:284)
  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:401)
          at org.apache.spark.api.java.JavaSparkContext.&lt;init&gt;(JavaSparkContext.scala:59)
          at com.ts.clustering.TrainModel.&lt;clinit&gt;(TrainModel.java:35)
          ... 21 more
  </code></pre>
  
  <p>I have gone through couple of similar posts but nothing helped. Any suggestion would be great help.</p>