org.apache.hive.service.cli.HiveSQLException: java

2019-07-25 00:00发布

I am trying to connect my hive jdbc client to hiveserver2. i am using following 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.

but when i start my jdbc client with followin code :

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))

it gives me following exception :

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)

Can anybody either help me to identify the reason of this or solution please.

Thanks in advance.

标签: java hadoop hive
1条回答
手持菜刀,她持情操
2楼-- · 2019-07-25 00:49

This could happen due to multiple reason:-

  1. Either the corresponding jar wont be available which is the hivejdbcdriver jar with the right version eg: "hive-jdbc-1.2.1.jar" or sometimes you may to use "hive-jdbc-1.2.1-standalone.jar"(depending upon on how your usecase is) in the libraries folder or .m2 repository.
  2. Or,it could also be the jar may not be added in your classpath(add an entry for this jar in your .classpath file), depending upon how your application is built.
查看更多
登录 后发表回答