sbt package
運行得很好,但後,我得到的錯誤:阿帕奇星火:java.lang.NoSuchMethodError .rddToPairRDDFunctions
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.spark.SparkContext$.rddToPairRDDFunctions(Lorg/apache/spark/rdd/RDD;Lscala/reflect/ClassTag;Lscala/reflect/ClassTag;Lscala/math/Ordering;)Lorg/apache/spark/rdd/PairRDDFunctions; at SmokeStack$.main(SmokeStack.scala:46) at SmokeStack.main(SmokeStack.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:736) at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:185) at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:210) at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:124) at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
這裏是有問題的行:
val sigCounts = rowData.map(row => (row("Signature"), 1)).countByKey()
rowData
是RDD映射[字符串,字符串]。地圖中的所有項目都存在「簽名」鍵。
我懷疑這可能是一個構建問題。以下是我的sbt文件:
name := "Example1"
version := "0.1"
scalaVersion := "2.11.8"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.2.0"
scalacOptions ++= Seq("-feature")
我是新來的斯卡拉,所以也許進口是不正確的?我有:
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import scala.io.Source
你的編譯和運行時版本不匹配。 – maasg
這是相當舊的Spark版本。嘗試使用一個更新的。如上所述 - 你的運行時和編譯時間版本不匹配。 – JiriS
@maasg我將編譯和運行時Spark版本更改爲匹配,並且一切正常。你可以把這個作爲答案,我可以接受它嗎? – BlackSheep