Spark and Cassandra Java application: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/sql/Dataset
<p>I got an amazingly siplme java application which I almost copied from this one example: <a href="http://markmail.org/download.xqy?id=zua6upabiylzeetp&amp;number=2" rel="nofollow">http://markmail.org/download.xqy?id=zua6upabiylzeetp&amp;number=2</a></p>

<p>All I wanted to do is to read the table data and display in the Eclipse console.</p>

<p>My pom.xml:</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;chat_connaction_test&lt;/groupId&gt;
  &lt;artifactId&gt;ChatSparkConnectionTest&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
 &lt;dependencies&gt; 
    &lt;dependency&gt;
    &lt;groupId&gt;com.datastax.cassandra&lt;/groupId&gt;
    &lt;artifactId&gt;cassandra-driver-core&lt;/artifactId&gt;
    &lt;version&gt;3.1.0&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
    &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
    &lt;artifactId&gt;spark-core_2.10&lt;/artifactId&gt;
    &lt;version&gt;2.0.0&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- https://mvnrepository.com/artifact/com.datastax.spark/spark-cassandra-connector_2.10 --&gt;
    &lt;dependency&gt;
    &lt;groupId&gt;com.datastax.spark&lt;/groupId&gt;
    &lt;artifactId&gt;spark-cassandra-connector_2.10&lt;/artifactId&gt;
    &lt;version&gt;2.0.0-M3&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- https://mvnrepository.com/artifact/org.apache.spark/spark-streaming_2.10 --&gt;
    &lt;dependency&gt;
    &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
    &lt;artifactId&gt;spark-streaming_2.10&lt;/artifactId&gt;
    &lt;version&gt;2.0.0&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.10&lt;/artifactId&gt; 
    &lt;version&gt;1.5.2&lt;/version&gt; 
    &lt;/dependency&gt;
    --&gt;
  &lt;/dependencies&gt;
&lt;/project&gt;
</code></pre>

<p>And my java code:</p>

<pre><code>    package com.chatSparkConnactionTest;

import static com.datastax.spark.connector.japi.CassandraJavaUtil.javaFunctions;
import java.io.Serializable;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.Function;
import com.datastax.spark.connector.japi.CassandraRow;

public class JavaDemo implements Serializable {
    private static final long serialVersionUID = 1L;
    public static void main(String[] args) {

        SparkConf conf = new SparkConf().
            setAppName("chat").
            setMaster("local").
            set("spark.executor.memory","1g").
            set("spark.cassandra.connection.host", "127.0.0.1");
        JavaSparkContext sc = new JavaSparkContext(conf);

        JavaRDD&lt;String&gt; cassandraRowsRDD = javaFunctions(sc).cassandraTable(
            "chat", "dictionary")

            .map(new Function&lt;CassandraRow, String&gt;() {
                @Override
                public String call(CassandraRow cassandraRow) throws Exception {
                    String tempResult = cassandraRow.toString();
                    System.out.println(tempResult);
                    return tempResult;
                    }
                }
            );
        System.out.println("Data as CassandraRows: \n" + 
        cassandraRowsRDD.collect().size()); // THIS IS A LINE WITH ERROR
    } 
}
</code></pre>

<p>And here is my error:</p>

<blockquote>
  <p>16/10/05 20:49:18 INFO CassandraConnector: Connected to Cassandra
  cluster: Test Cluster Exception in thread "main"
  java.lang.NoClassDefFoundError: org/apache/spark/sql/Dataset  at
  java.lang.Class.getDeclaredMethods0(Native Method)    at
  java.lang.Class.privateGetDeclaredMethods(Unknown Source)     at
  java.lang.Class.getDeclaredMethod(Unknown Source)     at
  java.io.ObjectStreamClass.getPrivateMethod(Unknown Source)    at
  java.io.ObjectStreamClass.access$1700(Unknown Source)     at
  java.io.ObjectStreamClass$2.run(Unknown Source)   at
  java.io.ObjectStreamClass$2.run(Unknown Source)   at
  java.security.AccessController.doPrivileged(Native Method)    at
  java.io.ObjectStreamClass.(Unknown Source)  at
  java.io.ObjectStreamClass.lookup(Unknown Source)  at
  java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
  java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)     at
  java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
  java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
  java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
  java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)     at
  java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
  java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
  java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
  java.io.ObjectOutputStream.writeObject(Unknown Source)    at
  scala.collection.immutable.$colon$colon.writeObject(List.scala:379)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
  sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
  java.lang.reflect.Method.invoke(Unknown Source)   at
  java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)   at
  java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
  java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
  java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
  java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)     at
  java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
  java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
  java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
  java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)     at
  java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
  java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
  java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
  java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)     at
  java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
  java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
  java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
  java.io.ObjectOutputStream.writeObject(Unknown Source)    at
  org.apache.spark.serializer.JavaSerializationStream.writeObject(JavaSerializer.scala:43)
    at
  org.apache.spark.serializer.JavaSerializerInstance.serialize(JavaSerializer.scala:100)
    at
  org.apache.spark.util.ClosureCleaner$.ensureSerializable(ClosureCleaner.scala:295)
    at
  org.apache.spark.util.ClosureCleaner$.org$apache$spark$util$ClosureCleaner$$clean(ClosureCleaner.scala:288)
    at
  org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:108)
    at org.apache.spark.SparkContext.clean(SparkContext.scala:2037)     at
  org.apache.spark.SparkContext.runJob(SparkContext.scala:1896)     at
  org.apache.spark.SparkContext.runJob(SparkContext.scala:1911)     at
  org.apache.spark.rdd.RDD$$anonfun$collect$1.apply(RDD.scala:893)  at
  org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
    at
  org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
    at org.apache.spark.rdd.RDD.withScope(RDD.scala:358)    at
  org.apache.spark.rdd.RDD.collect(RDD.scala:892)   at
  org.apache.spark.api.java.JavaRDDLike$class.collect(JavaRDDLike.scala:360)
    at
  org.apache.spark.api.java.AbstractJavaRDDLike.collect(JavaRDDLike.scala:45)
    at com.chatSparkConnactionTest.JavaDemo.main(JavaDemo.java:37) Caused
  by: java.lang.ClassNotFoundException: org.apache.spark.sql.Dataset    at
  java.net.URLClassLoader.findClass(Unknown Source)     at
  java.lang.ClassLoader.loadClass(Unknown Source)   at
  sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)    at
  java.lang.ClassLoader.loadClass(Unknown Source)   ... 58 more</p>
</blockquote>

<p>I made my pom.xml updated but that didn't resolve the error. Could anybody help me to resolve this problem?</p>

<p>Thank you!</p>

<p>Update 1:
here is my build path screenshot:
<a href="http://i.stack.imgur.com/uQhp9.png" rel="nofollow">Link to my screenshot</a></p>