title: Spark/Java: NoClassDefFoundError in GSON dependency
body: <p>I have a small Spark project using a JAR file, which I am packaging with Maven.</p>
  
  <p>I am using GSON to work with JSON files, and I specifically need the JsonReader class.</p>
  
  <p>I added the GSON dependency, and when I run it as a standard Java project it works fine. However, when I package it and run it in Spark it complains:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/stream/JsonReader
  </code></pre>
  
  <p>Here is the line in question:</p>
  
  <pre><code>reader = new JsonReader(new InputStreamReader(new FileInputStream(
                  jsonfile)));
  </code></pre>
  
  <p>I did import it:</p>
  
  <pre><code>import com.google.gson.*;
  import com.google.gson.stream.JsonReader;
  </code></pre>
  
  <p>Here is my POM file:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;SWETesting&lt;/groupId&gt;
    &lt;artifactId&gt;SWETesting&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;build&gt;
      &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.1&lt;/version&gt;
          &lt;configuration&gt;
            &lt;source/&gt;
            &lt;target/&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-core_2.11&lt;/artifactId&gt;
          &lt;version&gt;1.2.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jsoup&lt;/groupId&gt;
          &lt;artifactId&gt;jsoup&lt;/artifactId&gt;
          &lt;version&gt;1.8.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
          &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;version&gt;2.3.1&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I even installed libgoogle-gson in my distribution, but that didn't help. </p>
  
  <p>What is the problem here?</p>
  
  <p>Edit: I am submitting the job in standalone mode after building it with Maven:</p>
  
  <pre><code>mvn package
  /home/chris/Tools/spark-1.2.1/bin/spark-submit --class PlagiarismCheck --master local[6] target/SWETesting-0.0.1-SNAPSHOT.jar &gt; output.txt
  </code></pre>