我是Spark和Scala的新手。我已经用SBT创建了一个IntelliJ Scala项目,并添加了几行build.sbt。
name := "test-one" version := "1.0" scalaVersion := "2.11.2" libraryDependencies += "org.apache.spark" % "spark-core_2.10" % "1.1.0"
我的Scala版本是2.10.4,但这个问题也发生在2.11.2
Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class at akka.util.Collections$EmptyImmutableSeq$.<init>(Collections.scala:15) at akka.util.Collections$EmptyImmutableSeq$.<clinit>(Collections.scala) at akka.japi.Util$.immutableSeq(JavaAPI.scala:209) at akka.actor.ActorSystem$Settings.<init>(ActorSystem.scala:150) at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:470) at akka.actor.ActorSystem$.apply(ActorSystem.scala:111) at akka.actor.ActorSystem$.apply(ActorSystem.scala:104) at org.apache.spark.util.AkkaUtils$.org$apache$spark$util$AkkaUtils$$doCreateActorSystem(AkkaUtils.scala:121) at org.apache.spark.util.AkkaUtils$$anonfun$1.apply(AkkaUtils.scala:54) at org.apache.spark.util.AkkaUtils$$anonfun$1.apply(AkkaUtils.scala:53) at org.apache.spark.util.Utils$$anonfun$startServiceOnPort$1.apply$mcVI$sp(Utils.scala:1446) at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:160) at org.apache.spark.util.Utils$.startServiceOnPort(Utils.scala:1442) at org.apache.spark.util.AkkaUtils$.createActorSystem(AkkaUtils.scala:56) at org.apache.spark.SparkEnv$.create(SparkEnv.scala:153) at org.apache.spark.SparkContext.<init>(SparkContext.scala:203) at TweeProcessor$.main(TweeProcessor.scala:10) at TweeProcessor.main(TweeProcessor.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: java.lang.classNotFoundException: scala.collection.GenTraversableOnce$class at java.net.urlclassloader$1.run(urlclassloader.java:366) at java.net.urlclassloader$1.run(urlclassloader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.urlclassloader.findClass(urlclassloader.java:354) at java.lang.classLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.classLoader.loadClass(ClassLoader.java:358) ... 23 more
解决方法
spark-core_2.10是用于2.10.x版本的scala的。你应该使用
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.1.0"
这将为您的scala版本选择正确的_2.10或_2.11版本。
还要确保您正在编译与您运行此操作的群集上相同版本的scala和spark。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。