我正在尝试让 Cassandra 2.2.3(在 localhost 上运行)与 Spark 1.5.1 和最新版本的 spark-cassandra-connector (1.5.0-M2) 一起使用。
这是我正在使用的基本代码段。键空间和表已经创建。
import com.datastax.spark.connector._
import org.apache.spark.{SparkConf, SparkContext}
val conf = new SparkConf().setMaster("local[*]").set("spark.cassandra.connection.host", "localhost")
val sc = new SparkContext(conf)
val collection = sc.parallelize(Seq(("word1", 30), ("word2", 40)))
collection.saveToCassandra("test", "words", SomeColumns("word", "count"))
sbt 程序集编译时没有任何问题,但在提交应用程序时出现此错误:
Exception in thread "main" java.lang.NoSuchMethodError: scala.reflect.api.JavaUniverse.runtimeMirror(Ljava/lang/ClassLoader;)Lscala/reflect/api/JavaUniverse$JavaMirror;
at Streamer$.main(Streamer.scala:33)
at Streamer.main(Streamer.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:483)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:672)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:180)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:205)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:120)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)