5

enter image description hereReferring to Hive2 created a simple java program to connect to HIVE2 server (not local) have added all mentioned jars in the above link in the class path in eclipse as well however when I run the code it throws an error as:

09:42:35,580  INFO Utils:285 - Supplied authorities: hdstg-c01-edge-03:20000
09:42:35,583  INFO Utils:372 - Resolved authority: hdstg-c01-edge-03:20000
09:42:35,656  INFO HiveConnection:189 - Will try to open client transport with JDBC Uri: jdbc:hive2://hdstg-c01-edge-03:20000
FAILED: f
java.lang.NoSuchMethodError: org.apache.thrift.protocol.TProtocol.getScheme()Ljava/lang/Class;
at org.apache.hive.service.cli.thrift.TCLIService$OpenSession_args.write(TCLIService.java:1854)
at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:63)
at org.apache.hive.service.cli.thrift.TCLIService$Client.send_OpenSession(TCLIService.java:150)
at org.apache.hive.service.cli.thrift.TCLIService$Client.OpenSession(TCLIService.java:142)
at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:456)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:178)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:221)
at testScripts.HiveJdbcClient.f(HiveJdbcClient.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:648)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:834)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:771)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Referred here and here but it did not resolve the problem.

Community
  • 1
  • 1
Vinod
  • 376
  • 2
  • 11
  • 34
  • Have you added all jar libs including thrift? It looks like you have not added thrift jar file. – Mobin Ranjbar Dec 31 '15 at 08:06
  • @MobinRanjbar: Yes its added updated with screen shot of it. – Vinod Dec 31 '15 at 09:46
  • Try to downgrade your libthrift version to an older version like 0.8.0 or 0.7.0. – Mobin Ranjbar Dec 31 '15 at 13:10
  • @MobinRanjbar: Ran with 0.8 and getting this error now: java.lang.NoClassDefFoundError: org/apache/thrift/scheme/StandardScheme – Vinod Jan 01 '16 at 04:54
  • after few unsuccessful run again its displaying with same old error. – Vinod Jan 01 '16 at 06:15
  • Still lools like you have multiple versions of thrift in classpath. Do you import libraries/maven depejdencies or the like adding another, older version? – Jan Jan 01 '16 at 07:41
  • @Jan: I am not using Maven so am adding it manually, build path>add external JARS. and am doing a clean, restart and then running – Vinod Jan 01 '16 at 07:43

1 Answers1

4

You use a hive2 type jdbc url.

As explained in Hive wiki, the thrift jdbc is no longer recommended:

JDBC

This document describes the JDBC client for the original Hive Server (sometimes called Thrift server or HiveServer1). For information about the HiveServer2 JDBC client, see JDBC in the HiveServer2 Clients document. HiveServer2 use is recommended; the original HiveServer has several concurrency issues and lacks several features available in HiveServer2.

Checkout this info on hive2 jdbc. Driver can be found here for instance:

http://mvnrepository.com/artifact/org.apache.hive/hive-jdbc/1.2.1

Jan
  • 13,738
  • 3
  • 30
  • 55
  • Went through JARS one by one and rebuilt the project, as you said it was due to incompatible JAR version issue, now its resolved and I am able to connect to hive, thanks – Vinod Jan 03 '16 at 12:17
  • @Jan is thrift jdbc really not recommended? Just one page away on the same wiki it says that HiveServer2 "includes the Thrift-based Hive server". (https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Overview). I can't figure out if I should be hunting for thrift jars or not... – martin jakubik Nov 16 '16 at 16:24
  • What do you mean "JDBC no longer recommended" ? – Thomas Decaux Aug 24 '17 at 10:21