java.lang.noclassdeffounderror上的错误:org/apache/spark/sql/sqlcontext

ztigrdn8  于 2021-06-27  发布在  Hive
关注(0)|答案(1)|浏览(621)

在我的windows机器上通过intellij运行代码时,我遇到了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,然后当我声明如下时,它也给予noClassDefFoundErrorForSQLContext

val hc = new HiveContext(sc) or val hc = new SQLCOntext(sc)

如果我删除%“provided”%,而sbt build我得到以下错误。

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

你能帮我解决这个问题吗。
谢谢,巴布

hiz5n14c

hiz5n14c1#

尝试将spark core添加到您的sbt依赖项中。

相关问题