My configuration is:
I want run this simple scala code (Esempio.scala):
package it.scala
// importo packages di Spark
import org.apache.spark.SparkContext
import org.apache.spark.SparkConf
object Wordcount {
    def main(args: Array[String]) {
        val inputs: Array[String] = new Array[String](2)
        inputs(0) = "C:\\Users\\FobiDell\\Desktop\\input"
        inputs(1) = "C:\\Users\\FobiDell\\Desktop\\output"
        // oggetto SparkConf per settare i parametri sulla propria applicazione 
        // da fornire poi al cluster manager scelto (Yarn, Mesos o Standalone).
        val conf = new SparkConf()
        conf.setAppName("Smartphone Addiction")
        conf.setMaster("local")
        // oggetto SparkContext per connessione al cluster manager scelto
        val sc = new SparkContext(conf)
        //Read file and create RDD
        val rawData = sc.textFile(inputs(0))
        //convert the lines into words using flatMap operation
        val words = rawData.flatMap(line => line.split(" "))
        //count the individual words using map and reduceByKey operation
        val wordCount = words.map(word => (word, 1)).reduceByKey(_ + _)
        //Save the result
        wordCount.saveAsTextFile(inputs(1))
       //stop the spark context
       sc.stop
   }
}
So, if I use the Spark-shell everything is ok otherwise, from Eclipse IDE, if I select the file (Esempio.scala) and run it via Run->Run as->Scala application, I obtain this Exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.spark.SparkContext.withScope(SparkContext.scala:701)
    at org.apache.spark.SparkContext.textFile(SparkContext.scala:830)
    at it.scala.Wordcount$.main(Esempio.scala:47)
    at it.scala.Wordcount.main(Esempio.scala)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Incompatible Jackson version: 2.8.8
    at com.fasterxml.jackson.module.scala.JacksonModule$class.setupModule(JacksonModule.scala:64)
    at com.fasterxml.jackson.module.scala.DefaultScalaModule.setupModule(DefaultScalaModule.scala:19)
    at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:745)
    at org.apache.spark.rdd.RDDOperationScope$.<init>(RDDOperationScope.scala:82)
    at org.apache.spark.rdd.RDDOperationScope$.<clinit>(RDDOperationScope.scala)
    ... 4 more  
My pom.xml file is:
<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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>it.hgfhgf.xhgfghf</groupId>
  <artifactId>progetto</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>progetto</name>
  <url>http://maven.apache.org</url>
  <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <!-- Neo4j JDBC DRIVER -->
    <dependency>
      <groupId>org.neo4j</groupId>
      <artifactId>neo4j-jdbc-driver</artifactId>
      <version>3.1.0</version>
    </dependency>
    <!-- Scala -->
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>2.11.11</version>
    </dependency> 
    <!-- Spark -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.11</artifactId>
      <version>2.2.1</version>
    </dependency>
  </dependencies>
</project>
I noticed that the .jar files that are into spark-2.2.1-bin-hadoop2.7/jars directory are:
Can anyone explain to me in simple terms what this exception is and how can it be resolved?
Spark 2.x contains the jackson 2.6.5  and neo4j-jdbc-driver uses jackson 2.8.8 version, here the dependency conflict between two different version of jackson library.
That's why you are getting this Incompatible Jackson version: 2.8.8 error.
Try to override the dependency version for these[below] modules inside your pom.xml and see if works,
or try adding below dependency into your pom.xml
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-scala_2.11</artifactId>
            <version>2.8.8</version>
        </dependency> 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With