在通过intellij在Windows计算机中运行代码时,我面临org.apache.spark.sql.hive.HiveContext或org.apache.spark.sql.SQLContext的NoClassDefFoundError
我有以下build.sbt。
name := "sample"
version := "1.0"
scalaVersion := "2.10.6"
resolvers += "Maven Central" at "https://repo.maven.apache.org/maven2/"
resolvers += "Hortonworks Releases" at "http://repo.hortonworks.com/content/repositories/releases/"
resolvers += "Nexus Repository Releases" at "http://10.85.114.41/content/repositories/releases/"
libraryDependencies ++={
val hortonVer = "1.6.2.2.5.0.0-1245"
val elasticVer = "5.0.0"
val kafkaVer = "0.10.0.2.5.0.0-1245"
Seq(
"org.apache.spark" % "spark-sql_2.10" % hortonVer % "provided" exclude("org.mortbay.jetty", "jetty") exclude("org.mortbay.jetty", "jetty-util") exclude("net.minidev", "json-smart"),
"org.apache.spark" % "spark-hive_2.10" % hortonVer % "provided",
"org.elasticsearch" % "elasticsearch-spark-13_2.10" % elasticVer exclude("org.apache.spark", "spark-streaming-kafka_2.10") exclude("org.apache.spark", "spark-core_2.10") exclude("org.apache.spark", "spark-sql_2.10") exclude("org.mortbay.jetty", "jetty") exclude("org.mortbay.jetty", "jetty-util") exclude ("org.spark-project.spark", "unused"),
"com.sample.app" % "cap-spark-api-01" % "1.0.7" exclude("org.apache.spark", "spark-streaming-kafka_2.10") exclude("org.mortbay.jetty", "jetty") exclude("org.mortbay.jetty", "jetty-util") exclude("com.datastax.spark", "spark-cassandra-connector_2.10") exclude ("org.elasticsearch", "elasticsearch-spark-13_2.10"),
"org.apache.kafka" % "kafka-clients" % kafkaVer
)
}
assemblyJarName in assembly := "sample.jar"
我已经在代码中导入了org.apache.spark.sql.hive.HiveContext并获取了NoClassDefFoundError异常。
当HiveContext给出NoClassDefFoundErroracception时,我已经导入了org.apache.spark.sql.SQLContext,然后在我声明如下时也为SQLContext给出了NoClassDefFoundError
val hc = new HiveContext(sc) or val hc = new SQLCOntext(sc)
如果在sbt构建时删除%“提供的”%,则会出现以下错误。
sbt.librarymanagement.ResolveException: unresolved dependency: org.mortbay.jetty#jetty-util;6.1.26.hwx: Nexus Repository Releases: unable to get resource for org/mortbay/jetty#jetty-util;6.1.26.hwx: res=http://10.85.114.41/content/repositories/releases/org/mortbay/jetty/jetty-util/6.1.26.hwx/jetty-util-6.1.26.hwx.pom: java.net.ConnectException: Failed to connect to /10.85.114.41:80
您能帮我解决这个问题吗?
谢谢,宝贝
答案 0 :(得分:0)
尝试将spark-core添加到您的SBT依赖项中。