1

即使使用最简单的示例(如下) ,我也正在尝试使用hive warehouse connector并获得异常。导致问题的类:- 位于(spark_sql 的依赖项)和.sparkhdp 3.1JaninoRuntimeExceptionorg.codehaus.janino:janino:jar:3.0.8com.hortonworks.hive:hive-warehouse-connector_2.11:jar

我试图从 spark_sql 中排除 janino 库,但这导致 janino 中缺少其他类。我需要 hwc 来获得新功能。

有人有同样的错误吗?任何想法如何处理它?

我收到错误:

Exception in thread "main" java.lang.reflect.InvocationTargetException
    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 com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:66)
Caused by: java.lang.SecurityException: class "org.codehaus.janino.JaninoRuntimeException"'s signer information does not match signer information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(ClassLoader.java:898)
    at java.lang.ClassLoader.preDefineClass(ClassLoader.java:668)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:761)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.apache.spark.sql.catalyst.expressions.codegen.GenerateSafeProjection$.create(GenerateSafeProjection.scala:197)
    at org.apache.spark.sql.catalyst.expressions.codegen.GenerateSafeProjection$.create(GenerateSafeProjection.scala:36)
    at org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator.generate(CodeGenerator.scala:1321)
    at org.apache.spark.sql.Dataset.org$apache$spark$sql$Dataset$$collectFromPlan(Dataset.scala:3277)
    at org.apache.spark.sql.Dataset$$anonfun$head$1.apply(Dataset.scala:2489)
    at org.apache.spark.sql.Dataset$$anonfun$head$1.apply(Dataset.scala:2489)
    at org.apache.spark.sql.Dataset$$anonfun$52.apply(Dataset.scala:3259)
    at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:77)
    at org.apache.spark.sql.Dataset.withAction(Dataset.scala:3258)
    at org.apache.spark.sql.Dataset.head(Dataset.scala:2489)
    at org.apache.spark.sql.Dataset.take(Dataset.scala:2703)
    at org.apache.spark.sql.Dataset.showString(Dataset.scala:254)
    at org.apache.spark.sql.Dataset.show(Dataset.scala:723)
    at org.apache.spark.sql.Dataset.show(Dataset.scala:682)
    at org.apache.spark.sql.Dataset.show(Dataset.scala:691)
    at Main$.main(Main.scala:15)
    at Main.main(Main.scala)
    ... 5 more

我的 sbt 文件:

name := "testHwc"

version := "0.1"

scalaVersion := "2.11.11"

resolvers += "Hortonworks repo" at "http://repo.hortonworks.com/content/repositories/releases/"

libraryDependencies += "org.apache.hadoop" % "hadoop-aws" % "3.1.1.3.1.0.0-78"

// https://mvnrepository.com/artifact/com.hortonworks.hive/hive-warehouse-connector
libraryDependencies += "com.hortonworks.hive" %% "hive-warehouse-connector" % "1.0.0.3.1.0.0-78"

libraryDependencies += "org.apache.spark" %% "spark-core" % "2.3.2.3.1.0.0-78"

libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.3.2.3.1.0.0-78"

和源代码:

import com.hortonworks.hwc.HiveWarehouseSession
import org.apache.spark.sql.SparkSession

object Main {
  def main(args: Array[String]): Unit = {

    val ss = SparkSession.builder()
      .config("spark.sql.hive.hiveserver2.jdbc.url", "nnn")
      .master("local[*]").getOrCreate()

    import ss.sqlContext.implicits._

    val rdd = ss.sparkContext.makeRDD(Seq(1, 2, 3, 4, 5, 6, 7))

    rdd.toDF("col1").show()
    val hive = HiveWarehouseSession.session(ss).build()
  }
}
4

1 回答 1

1

经过一番调查,我发现错误的存在取决于classpath.

由于未知原因,当我在 IntelliJ IDEA 中运行这个项目时,类路径总是随机顺序,应用程序失败并随机成功。

最后 - HiveWarehouseConnectorjar inclasspath应该 Spark Sqljar 之后。

更新

正如这个答案中所建议的 - IntelliJ IDEA 中的顺序可以在依赖项选项卡中更改。

否则 - 我无法为 IntelliJ 解决这个问题 - 顺序总是随机的,但是当我在 IntelliJ 之外执行程序时 - 我设置了我需要的顺序。

于 2019-06-20T12:51:16.707 回答