1
votes

I have a hive+hbase integration cluster.

When I try to execute query through the java client of hive, sometimes a ClassNotFoundException happens.

My java code :

final Connection conn = DriverManager.getConnection(URL);
final ResultSet rs = conn.executeQuery("SELECT count(*) FROM test_table WHERE (source = '0' AND ur_createtime BETWEEN '20121031000000' AND '20121031235959')");

I can execute the sql:SELECT count(*) FROM test_table WHERE (source = '0' AND ur_createtime BETWEEN '20121031000000' AND '20121031235959') in hive cli mod, and get the query result, so there is no error in my sql.

The client side exception:

Caused by: java.sql.SQLException: Query returned non-zero code: 9, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask
    at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:189)
... 23 more

The server side exception(hadoop-jobtracker):

2012-11-05 18:55:39,443 INFO org.apache.hadoop.mapred.TaskInProgress: Error from attempt_201210301133_0112_m_000000_3: java.io.IOException: Cannot create an instance of InputSplit class = org.apache.hadoop.hive.hbase.HBaseSplit:org.apache.hadoop.hive.hbase.HBaseSplit
    at org.apache.hadoop.hive.ql.io.HiveInputFormat$HiveInputSplit.readFields(HiveInputFormat.java:146)
    at org.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:67)
    at org.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:40)
    at org.apache.hadoop.mapred.MapTask.getSplitDetails(MapTask.java:396)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:412)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
    at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Unknown Source)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1059)
    at org.apache.hadoop.mapred.Child.main(Child.java:249)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hive.hbase.HBaseSplit
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:819)
    at org.apache.hadoop.hive.ql.io.HiveInputFormat$HiveInputSplit.readFields(HiveInputFormat.java:143)
    ... 10 more

My hive-env.sh

export HIVE_AUX_JARS_PATH=/data/install/hive-0.9.0/lib/hive-hbase-handler-0.9.0.jar,/data/install/hive-0.9.0/lib/hbase-0.92.0.jar,/data/install/hive-0.9.0/lib/zookeeper-3.4.2.jar

My hive-site.xml

<property>
    <name>hive.zookeeper.quorum</name>
    <value>hadoop01,hadoop02,hadoop03</value>
    <description>The list of zookeeper servers to talk to. This is only needed for read/write locks.</description>
</property>

And I start thrift service as below:

hive --service hiveserver -p 10000 &

The server side error log says that HBaseSplit is not found. But why? How can I fix this?

3

3 Answers

2
votes

In case you do not have access to config files, you can add the jars to the hive cli classpath using the --auxpath switch:

hive --auxpath /path/to/hive-hbase-handler-0.10.0-cdh4.2.0.jar,/path/to/hbase.jar 
1
votes
  1. create a folder auxlib in $HIVE_HOME and put all hive-hbase-handler, hbase jars to that folder

  2. Add following lines to $HIVE_HOME/conf/hive-site.xml

    <property>
     <name>hive.aux.jars.path</name>
     <value>file:///<absolute-path-of-all-auxlib-jars></value>
    </property>
    

    restart hive server

0
votes

The workaround for this problem is either you can copy the jar files hive-hbase-handler-0.9.0-cdh4.1.2, hbase-0.92.1-cdh4.1.2-security etc to HADOOP lib folder or add the path to these jars in HADOOP_CLASSPATH environment variable.