Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found

I'am trying to build spark streaming application using sbt package,I can't discover what's the reason of this error.

this is some thing of the error

scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found. at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:16) at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:17) at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:48) at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:40) at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:40)

and here is the code

import org.apache.spark.SparkContext import org.apache.spark._ import org.apache.spark.streaming._ import org.apache.spark.streaming.twitter._ import twitter4j.Status object TrendingHashTags { def main(args: Array[String]): Unit = { val Array(consumerKey, consumerSecret, accessToken, accessTokenSecret, lang, batchInterval, minThreshold, showCount ) = args.take(8) val filters = args.takeRight(args.length - 8) System.setProperty("twitter4j.oauth.consumerKey", consumerKey) System.setProperty("twitter4j.oauth.consumerSecret", consumerSecret) System.setProperty("twitter4j.oauth.accessToken", accessToken) System.setProperty("twitter4j.oauth.accessTokenSecret", accessTokenSecret) val conf = new SparkConf().setAppName("TrendingHashTags") val ssc = new StreamingContext(conf, Seconds(batchInterval.toInt)) val tweets = TwitterUtils.createStream(ssc, None, filters) val tweetsFilteredByLang = tweets.filter{tweet => tweet.getLang() == lang} val statuses = tweetsFilteredByLang.map{ tweet => tweet.getText()} val words = statuses.flatMap{status => status.split("""\s+""")} val hashTags = words.filter{word => word.startsWith("#")} val hashTagPairs = hashTags.map{hashtag => (hashtag, 1)} val tagsWithCounts = hashTagPairs.updateStateByKey( (counts: Seq[Int], prevCount: Option[Int]) => prevCount.map{c => c + counts.sum}.orElse{Some(counts.sum)} ) val topHashTags = tagsWithCounts.filter{ case(t, c) => c > minThreshold.toInt } val sortedTopHashTags = topHashTags.transform{ rdd => rdd.sortBy({case(w, c) => c}, false) } sortedTopHashTags.print(showCount.toInt) ssc.start() ssc.awaitTermination() } } 
like image 786
Elsayed Avatar asked Sep 30 '16 12:09

Elsayed


2 Answers

I solved this issue ,I found that I used java 9 that isn't compatible with scala version so I migrated from java 9 into java 8.

like image 158
Elsayed Avatar answered Oct 13 '22 20:10

Elsayed


I had faced this issue when I had to downgrade my projects Scala version to use a dependency that was compiled in a lower Scala version and could not resolved it even after I made sure JDK and all other dependencies are compatible with the downgraded Scala library version.

As @ForeverLearner mentioned above, deleting Scala library versions higher than the one I am now using to compile project from maven repo (/Users/<>/.m2/repository/org/scala-lang/scala-library/...) helped me get rid of this error

like image 25
grover Avatar answered Oct 13 '22 22:10

grover