1
votes

I am trying to connect to hive thrift server (hiveserver2) from web application. I created dynamic web project in Eclipse, and added following jars under WEB-INF/lib -

  • hive-jdbc-0.14.0-standalone.jar
  • hive-jdbc-0.14.0.jar
  • hadoop-common-2.6.0.jar
  • mongo-hadoop-core.jar
  • mongo-hadoop-hive.jar
  • mongo-java-driver.jar

I am using tomcat 7.0.61. When I deploy the application to tomcat server, it gives following message and does not load hive-jdbc-0.14.0-standalone.jar

INFO:     validateJarFile(C:\EclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\HiveWeb\WEB-INF\lib\hive-jdbc-0.14.0-standalone.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class

It seems javax.servlet.Servlet.class in hive-jdbc-0.14.0-standalone.jar and tomcat/lib are conflicting. I need hive-jdbc-0.14.0-standalone.jar for connecting to hiveserver.

I tried to add hive-jdbc-0.14.0-standalone.jar in tomcat/lib directory. But tomcat fail to start due to that.

Is there a way to exclude javax.servlet.Servlet from either hive-jdbc-0.14.0-standalone.jar or tomcat?

2
My guess would be that you should not include hive-jdbc-0.14.0-standalone.jar; you aren't running standalone. - Mark Rotteveel
@MarkRotteveel thank you for the reply. But I need hive-jdbc-0.14.0-standalone.jar for connecting to hive thrift server using jdbc. If I don't include that jar, java can not connect to hive server. - kshpra
I'd guess that hive-jdbc-0.14.0.jar should be sufficient - Mark Rotteveel
@MarkRotteveel I tried that, but if I include only hive-jdbc-0.14.0.jar, I get java.lang.ClassNotFoundException: org.apache.hive.service.cli.thrift.TCLIService$Iface - kshpra
Did you manage to solve your problem @kshpra? - dosaki

2 Answers

0
votes

You should try removing hive-jdbc-0.14.0-standalone.jar and use below jars :

hive-common--0.14.0.jar hive-exec-0.14.0.jar hive-metastore-0.14.0.jar hive-serde-0.14.0.jar hive-service-0.14.0.jar

0
votes

You guess right.

Tomecat/lib/servlet-api.jar includes javax.servlet conflicts with javax.servlet in hive-jdbc-x.x.x-standlone.jar.

I think it's not recommended to use hive-jdbc-x.x.x-standlone.jar when your app deployed to the production environment, cause hive-jdbc-x.x.x-standlone.jar includes many other resources, it's quite easy to conflict with other *.jar.

So just remove hive-jdbc-x.x.x-standlone.jar, and add the following jar to classpath(HAVE BEEN TESTED).

  1. hadoop-auth-x.x.x.jar
  2. hadoop-common-x.x.x.jar
  3. hadoop-mapreduce-client-core-x.x.x.jar
  4. hive-exec-x.x.x.jar
  5. hive-jdbc-x.x.x.jar
  6. hive-metastore-x.x.x.jar
  7. hive-service-x.x.x.jar