我对Scala很新,我正在尝试构建Spark工作。我已经构建了一个包含DataStax连接器的ajob并将其组装成一个胖罐。当我尝试执行它时失败并显示java.lang.NoSuchMethodError
。我已经破解了JAR并且可以看到包含DataStax库。我错过了一些明显的东西吗有关这个过程的好教程吗?
由于
控制台 $ spark-submit --class org.bobbrez.CasCountJob ./target/scala-2.11/bobbrez-spark-assembly-0.0.1.jar ks tn ... 线程“main”中的异常java.lang.NoSuchMethodError:scala.runtime.ObjectRef.zero()Lscala / runtime / ObjectRef; at com.datastax.spark.connector.cql.CassandraConnector $ .com $ datastax $ spark $ connector $ cql $ CassandraConnector $$ createSession(CassandraConnector.scala) 在com.datastax.spark.connector.cql.CassandraConnector $$ anonfun $ 2.apply(CassandraConnector.scala:148) ...
build.sbt
name := "soofa-spark"
version := "0.0.1"
scalaVersion := "2.11.7"
// additional libraries
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.6.0" % "provided"
libraryDependencies += "com.datastax.spark" %% "spark-cassandra-connector" % "1.5.0-M3"
libraryDependencies += "com.typesafe" % "config" % "1.3.0"
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case m if m.toLowerCase.endsWith("manifest.mf") => MergeStrategy.discard
case m if m.startsWith("META-INF") => MergeStrategy.discard
case PathList("javax", "servlet", xs @ _*) => MergeStrategy.first
case PathList("org", "apache", xs @ _*) => MergeStrategy.first
case PathList("org", "jboss", xs @ _*) => MergeStrategy.first
case "about.html" => MergeStrategy.rename
case "reference.conf" => MergeStrategy.concat
case _ => MergeStrategy.first
}
}
CasCountJob.scala
package org.bobbrez
// Spark
import org.apache.spark.{SparkContext, SparkConf}
import com.datastax.spark.connector._
object CasCountJob {
private val AppName = "CasCountJob"
def main(args: Array[String]) {
println("Hello world from " + AppName)
val keyspace = args(0)
val tablename = args(1)
println("Keyspace: " + keyspace)
println("Table: " + tablename)
// Configure and create a Scala Spark Context.
val conf = new SparkConf(true)
.set("spark.cassandra.connection.host", "HOSTNAME")
.set("spark.cassandra.auth.username", "USERNAME")
.set("spark.cassandra.auth.password", "PASSWORD")
.setAppName(AppName)
val sc = new SparkContext(conf)
val rdd = sc.cassandraTable(keyspace, tablename)
println("Table Count: " + rdd.count)
System.exit(0)
}
}
答案 0 :(得分:5)
Spark 1.6的Cassandra连接器仍在开发中,尚未发布。
对于将Cassandra与Spark集成,您至少需要以下依赖项: -
提到适当版本的Cassandra Libraries和Spark的映射here
显然,Spark 1.5的Cassandra连接器也在开发中,您可能会看到一些兼容性问题。 Cassandra连接器最稳定的版本适用于Spark 1.4,需要使用以下Jar文件: -
不用说,所有这些jar文件都应该被配置并可供执行者使用。