title: ERROR : User did not initialize spark context
body: <p>Log error :</p>
  
  <blockquote>
    <p>TestSuccessfull<br>
     2018-08-20 04:52:15 INFO  ApplicationMaster:54 - Final app status: FAILED, exitCode: 13
    2018-08-20 04:52:15 ERROR ApplicationMaster:91 - Uncaught exception: 
    java.lang.IllegalStateException: User did not initialize spark context!
        at org.apache.spark.deploy.yarn.ApplicationMaster.runDriver(ApplicationMaster.scala:498)
        at org.apache.spark.deploy.yarn.ApplicationMaster.org$apache$spark$deploy$yarn$ApplicationMaster$$runImpl(ApplicationMaster.scala:345)
        at org.apache.spark.deploy.yarn.ApplicationMaster$$anonfun$run$2.apply$mcV$sp(ApplicationMaster.scala:260)
        at org.apache.spark.deploy.yarn.ApplicationMaster$$anonfun$run$2.apply(ApplicationMaster.scala:260)
        at org.apache.spark.deploy.yarn.ApplicationMaster$$anonfun$run$2.apply(ApplicationMaster.scala:260)
        at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$5.run(ApplicationMaster.scala:800)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698)
        at org.apache.spark.deploy.yarn.ApplicationMaster.doAsUser(ApplicationMaster.scala:799)
        at org.apache.spark.deploy.yarn.ApplicationMaster.run(ApplicationMaster.scala:259)
        at org.apache.spark.deploy.yarn.ApplicationMaster$.main(ApplicationMaster.scala:824)
        at org.apache.spark.deploy.yarn.ApplicationMaster.main(ApplicationMaster.scala)
    2018-08-20 04:52:15 INFO  SparkContext:54 - Invoking stop() from shutdown hook</p>
  </blockquote>
  
  <p>Error log on console After submit command :</p>
  
  <blockquote>
    <p>2018-08-20 05:47:35 INFO  Client:54 - Application report for application_1534690018301_0035 (state: ACCEPTED)<br>
    2018-08-20 05:47:36 INFO  Client:54 - Application report for application_1534690018301_0035 (state: ACCEPTED)<br>
    2018-08-20 05:47:37 INFO  Client:54 - Application report for application_1534690018301_0035 (state: FAILED)<br>
    2018-08-20 05:47:37 INFO  Client:54 - 
         client token: N/A
         diagnostics: Application application_1534690018301_0035 failed 2 times due to AM Container for appattempt_1534690018301_0035_000002 exited with  exitCode: 13
    Failing this attempt.Diagnostics: [2018-08-20 05:47:36.454]Exception from container-launch.
    Container id: container_1534690018301_0035_02_000001
    Exit code: 13</p>
  </blockquote>
  
  <p>My code : </p>
  
  <pre><code>val sparkConf = new SparkConf().setAppName("Gathering Data")            
  val sc = new SparkContext(sparkConf)
  </code></pre>
  
  <p>submit command :</p>
  
  <p><code>spark-submit --class spark_basic.Test_Local --master yarn --deploy-mode cluster  /home/IdeaProjects/target/Spark-1.0-SNAPSHOT.jar</code></p>
  
  <p>discription : </p>
  
  <p>I have installed spark on hadoop in psedo distribustion mode.</p>
  
  <p><code>spark-shell</code> working fine. only problem when i used cluster mode .</p>
  
  <p>My code also work file . i am able print output but at final its giving error .</p>