Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class

Discussion in 'Big Data and Analytics' started by Mohammad Nazar Zahuruddin, Nov 1, 2017.

  1. Mohammad Nazar Zahuruddin

    Alumni

    Joined:
    Aug 25, 2017
    Messages:
    3
    Likes Received:
    0
    Hi,

    I'm trying to run my first scala program on eclipse IDE and I'm getting the following error. Appreciate your help.

    Scala code as below :
    package com.scala.prac1.core
    import org.apache.spark.SparkConf
    import org.apache.spark.SparkContext

    object FirstSparkProg {
    def main(args: Array[String]): Unit = {

    val conf = new SparkConf().setMaster("local").setAppName("FirstSparkProg")
    val sc = new SparkContext(conf)

    val numberArray = Array(1,2,3,4,5)
    val numRDD = sc.parallelize(numberArray)

    numRDD.collect().foreach(println)

    }

    }


    Exception got in eclipse IDE console as below:

    Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
    17/11/01 20:04:21 INFO SparkContext: Running Spark version 1.6.3
    Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class
    at org.apache.spark.util.TimeStampedWeakValueHashMap.<init>(TimeStampedWeakValueHashMap.scala:42)
    at org.apache.spark.SparkContext.<init>(SparkContext.scala:298)
    at com.scala.prac1.core.FirstSparkProg$.main(FirstSparkProg.scala:12)
    at com.scala.prac1.core.FirstSparkProg.main(FirstSparkProg.scala)
    Caused by: java.lang.ClassNotFoundException: scala.collection.GenTraversableOnce$class
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 4 more
     
    #1
  2. Mohammad Nazar Zahuruddin

    Alumni

    Joined:
    Aug 25, 2017
    Messages:
    3
    Likes Received:
    0
    Found it .. this was resolved by changing the "Scala Library Container" from 2.11.11 to 2.10.6. This can be done by right clicking the "Scala Library Container" on the left pane of Eclipse IDE > Click "Properties" > select 2.10.6 container > "Apply and close"
     
    #2
  3. _14857

    _14857 Member

    Joined:
    Nov 1, 2017
    Messages:
    7
    Likes Received:
    0
    Hi,

    Appreciate..Good work
     
    #3

Share This Page