0

I have used the JDBC api to connect to HIVE2 referring here, it was successful so for easy of access I thought of creating a webapp around it using JSP as front-end page to enter server name and query. While all parameters are resolved correctly from JSP page to servlet it throws an error while connecting to HIVE server its required to place libthrift and hive JARS in WEB-INF/lib directory I placed in both WEB-INF/lib and classpath.

Issue is as hive jar comes first in WEB-INF/lib and as it does not have "org.apache.thrift.protocol.TProtocol.getScheme()" method I keep getting no such method error. I referred here and here and moved the libthrift jar to WEB-INF/classes but it dint help:

Jar versions: libthrift-0.9.3 and hive-0.4.1

Community
  • 1
  • 1
Vinod
  • 376
  • 2
  • 11
  • 34
  • Are you serious about the Hive version?? V0.4.1 was released in **2009**; Cloudera distibution ships with V1.2 (and they are notoriously cautious); and V2.0 is available. – Samson Scharfrichter May 24 '16 at 17:04
  • @SamsonScharfrichter: Hi, I meant Hive2 in context of [link](https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-UsingJDBC) our hive server version is "hive-0.13" – Vinod May 24 '16 at 17:09
  • Hive2 usually refers to "HiveServer2", the 2nd-generation JDBC service. Nothing to do with Hive version proper. – Samson Scharfrichter May 24 '16 at 17:13
  • Ok... But it was working fine before... Just after trying to build web app it's failing – Vinod May 24 '16 at 17:14
  • I guess the ordering in WEB-INF/lib is the problem as hive-0.4.1 jar does not have "Tprotocol.getScheme()" method – Vinod May 24 '16 at 17:26

1 Answers1

1

If only your Hive version was more recent, you could...

But alas, you cannot user a driver that is more recent that your server -- here V0.13, i.e. the last version without a "standalone" driver JAR. So you've got a whole bunch of Hive JARs to collect, plus a couple of Hadoop JARs and various dependencies such as libfb303-*.jar and libthrift-*.jar

$ unzip -l libthrift-0.9.2.jar | grep org.apache.thrift.protocol.TProtocol.class

2958 11-05-2014 03:47 org/apache/thrift/protocol/TProtocol.class

Community
  • 1
  • 1
Samson Scharfrichter
  • 8,884
  • 1
  • 17
  • 36
  • Tried with this standalone jar got same issue, then removed all JARS and then added "hive-exec-0.12.0.jar", "hive-jdbc-0.12.0.jar" and "hive-service-0.13.1.jar" and tried to run the now getting this error: "java.lang.NoClassDefFoundError: org/apache/hadoop/hive/conf/HiveConf$ConfVars" – Vinod May 26 '16 at 16:44
  • Mixing JARs from different versions (here V0.12 and V0.13.1) is **not** a good idea... I guess your nickname is "daredevil" :-0 – Samson Scharfrichter May 26 '16 at 19:13
  • Anyway, in my answer I was trying to tell you "softly" that your original message was about some missing Thrift libraries (from Facebook). The "soft" attempt has visibly failed so I will try again loudly: **Hive uses Thrift protocol, you must put the Thrift libraries** i.e. `libfb303-*.jar` and `libthrift-*.jar` **in the _CLASSPATH_ of your app** -- unless they are already bundled in a "standalone" driver; **but with V0.13 you cannot use a "standalone" driver** – Samson Scharfrichter May 26 '16 at 19:17
  • :D sometimes softly does not work i guess... thanks... did as advised.. and its working now – Vinod May 27 '16 at 08:05