title: Spark sql and hive causing "Error: Could not find or load main class"
body: <p>I am new to big data. I have developed an spark application using Scala to communicate with hive. It is working fine on Intellij idea. But when I am building an jar file with all dependency I am getting the error </p>
  
  <blockquote>
    <p>Error: Could not find or load main class</p>
  </blockquote>
  
  <p>After further debugging I have found that when I am including spark SQL or hive then I am getting the error. It is a maven project. Please have a look on my pom.xml </p>
  
  <pre><code>&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;groupId&gt;spk&lt;/groupId&gt;
  &lt;artifactId&gt;spk&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
  &lt;dependencies&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core --&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;2.0.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-sql_2.11&lt;/artifactId&gt;
          &lt;version&gt;2.0.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!--&lt;dependency&gt;
          &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-hive_2.11&lt;/artifactId&gt;
          &lt;version&gt;2.0.2&lt;/version&gt;
      &lt;/dependency&gt;--&gt;
  
      &lt;!--&lt;dependency&gt;
          &lt;groupId&gt;org.apache.hive&lt;/groupId&gt;
          &lt;artifactId&gt;hive-exec&lt;/artifactId&gt;
          &lt;version&gt;1.2.2&lt;/version&gt;
      &lt;/dependency&gt;--&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;
          &lt;artifactId&gt;kafka_2.11&lt;/artifactId&gt;
          &lt;version&gt;2.0.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/com.101tec/zkclient --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.101tec&lt;/groupId&gt;
          &lt;artifactId&gt;zkclient&lt;/artifactId&gt;
          &lt;version&gt;0.11&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;
          &lt;artifactId&gt;kafka-clients&lt;/artifactId&gt;
          &lt;version&gt;0.10.0.0&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;sourceDirectory&gt;src/main/scala&lt;/sourceDirectory&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.scala-tools&lt;/groupId&gt;
              &lt;artifactId&gt;maven-scala-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.11&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;compile&lt;/goal&gt;
                          &lt;goal&gt;testCompile&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;args&gt;
                              &lt;!--&lt;arg&gt;-make:transitive&lt;/arg&gt;--&gt;
                              &lt;arg&gt;-dependencyfile&lt;/arg&gt;
                              &lt;arg&gt;${project.build.directory}/.scala_dependencies&lt;/arg&gt;
                          &lt;/args&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.11&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;useFile&gt;false&lt;/useFile&gt;
                  &lt;disableXmlReport&gt;true&lt;/disableXmlReport&gt;
                  &lt;!-- If you have classpath issue like NoDefClassError,... --&gt;
                  &lt;!-- useManifestOnlyJar&gt;false&lt;/useManifestOnlyJar --&gt;
                  &lt;includes&gt;
                      &lt;include&gt;**/*Test.*&lt;/include&gt;
                      &lt;include&gt;**/*Suite.*&lt;/include&gt;
                  &lt;/includes&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>