org.apache.hive.service.cli.HiveSQLException: java.lang.NoClassDefFoundError: org/apache/hadoop/ipc/CallerContext$Builder

org.apache.hive.service.cli.HiveSQLException: java.lang.NoClassDefFoundError: org/apache/hadoop/ipc/CallerContext$Builder

我正在尝试将我的配置单元 jdbc 客户端连接到 hiveserver2。 我正在使用以下 Maven

<dependency>
  <groupId>org.apache.hive</groupId>
  <artifactId>hive-service</artifactId>
  <version>1.2.1000.2.4.2.12-1</version>
</dependency>

hiveserver2.start() started my hiveserver2.

但是当我使用以下代码启动我的 jdbc 客户端时:

val con: Connection = DriverManager
      .getConnection("jdbc:hive2://localhost:10000/default", "", "")
    val stmt: Statement = con.createStatement
stmt.execute("create table if not exists student (id int))

它给了我以下异常:

org.apache.hive.service.cli.HiveSQLException: java.lang.NoClassDefFoundError: org/apache/hadoop/ipc/CallerContext$Builder at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:256) at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:242) at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:254)

谁能帮我找出这个问题的原因或解决方案。

提前致谢。

这可能由于多种原因而发生:-

  1. 要么对应的jar不可用 具有正确版本的 hivejdbcdriver jar 例如:"hive-jdbc-1.2.1.jar" 或者有时你可以使用 "hive-jdbc-1.2.1-standalone.jar"(取决于您的用例 是)在库文件夹或 .m2 存储库中。
  2. 或者,也可以 可能不会在您的类路径中添加 jar(为此添加一个条目 .classpath 文件中的 jar),具体取决于您的应用程序 建成。