title: Getting a Null Pointer Exception when I am trying to start PySpark
body: <p>I am starting pyspark using the following command</p>
  
  <pre><code>./bin/pyspark --master yarn --deploy-mode client --executor-memory 5g
  </code></pre>
  
  <p>And I get the following error</p>
  
  <pre><code>15/10/14 17:19:15 INFO spark.SparkContext: SparkContext already stopped.
  Traceback (most recent call last):
    File "/opt/spark-1.5.1/python/pyspark/shell.py", line 43, in &lt;module&gt;
      sc = SparkContext(pyFiles=add_files)
    File "/opt/spark-1.5.1/python/pyspark/context.py", line 113, in __init__
      conf, jsc, profiler_cls)
    File "/opt/spark-1.5.1/python/pyspark/context.py", line 178, in _do_init
      self._jvm.PythonAccumulatorParam(host, port))
    File "/opt/spark-1.5.1/python/lib/py4j-0.8.2.1-src.zip/py4j/java_gateway.py", line 701, in __call__
    File "/opt/spark-1.5.1/python/lib/py4j-0.8.2.1-src.zip/py4j/protocol.py", line 300, in get_return_value
  py4j.protocol.Py4JJavaError: An error occurred while calling None.org.apache.spark.api.python.PythonAccumulatorParam.
  : java.lang.NullPointerException
          at org.apache.spark.api.python.PythonAccumulatorParam.&lt;init&gt;(PythonRDD.scala:825)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
          at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:234)
          at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:379)
          at py4j.Gateway.invoke(Gateway.java:214)
          at py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:79)
          at py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:68)
          at py4j.GatewayConnection.run(GatewayConnection.java:207)
          at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>For some reason, I am also getting this message</p>
  
  <pre><code> ERROR cluster.YarnClientSchedulerBackend: Yarn application has already exited with state FINISHED!
  </code></pre>
  
  <p>And</p>
  
  <pre><code>WARN remote.ReliableDeliverySupervisor: Association with remote system [akka.tcp://sparkYarnAM@192.168.1.112:48644] has failed, address is now gated for [5000] ms. Reason: [Disassociated]
  </code></pre>
  
  <p>And probably this is why I the SparkContext is stopping.</p>
  
  <p>I am using Spark 1.5.1 and Hadoop 2.7.1 with Yarn 2.7.</p>
  
  <p>Does anyone know why the Yarn application exits before anything happens?</p>
  
  <p>For additional information, here is my yarn-site.xml</p>
  
  <pre><code>        &lt;property&gt;
                  &lt;name&gt;yarn.nodemanager.resource.memory-mb&lt;/name&gt;
                  &lt;value&gt;26624&lt;/value&gt;
          &lt;/property&gt;
          &lt;property&gt;
                  &lt;name&gt;yarn.scheduler.minimum-allocation-mb&lt;/name&gt;
                  &lt;value&gt;1024&lt;/value&gt;
          &lt;/property&gt;
          &lt;property&gt;
                  &lt;name&gt;yarn.scheduler.maximum-allocation-mb&lt;/name&gt;
                  &lt;value&gt;26624&lt;/value&gt;
          &lt;/property&gt;
          &lt;property&gt;
                  &lt;name&gt;yarn.nodemanager.vmem-pmem-ratio&lt;/name&gt;
                  &lt;value&gt;2.1&lt;/value&gt;
          &lt;/property&gt;
  </code></pre>
  
  <p>and here is my mapred-site.xml</p>
  
  <pre><code>    &lt;property&gt;
              &lt;name&gt;mapreduce.map.memory.mb&lt;/name&gt;
              &lt;value&gt;2048&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
              &lt;name&gt;mapreduce.map.java.opts&lt;/name&gt;
              &lt;value&gt;-Xmx1640M&lt;/value&gt;
              &lt;description&gt;Heap size for map jobs.&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
              &lt;name&gt;mapreduce.reduce.memory.mb&lt;/name&gt;
              &lt;value&gt;16384&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
              &lt;name&gt;mapreduce.reduce.java.opts&lt;/name&gt;
              &lt;value&gt;-Xmx13107M&lt;/value&gt;
              &lt;description&gt;Heap size for reduce jobs.&lt;/description&gt;
      &lt;/property&gt;
  </code></pre>