You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Melchiades Blanco Junior <lu...@gmail.com> on 2011/11/04 19:53:40 UTC

Problem running Hive Jdbc Client

Hey there, it's my first msg here. I'm trying to work with hive server by
connecting with its jdbc driver...

I have already hadoop and hive cli working...

I'm using this exemple of jdbc client:
https://cwiki.apache.org/confluence/display/Hive/HiveClient

*When I run the script, I get the following message:*

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/hadoop/io/Writable
at
org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:196)
 at
org.apache.hadoop.hive.jdbc.HiveStatement.execute(HiveStatement.java:130)
at
org.apache.hadoop.hive.jdbc.HiveConnection.configureConnection(HiveConnection.java:107)
 at
org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveConnection.java:102)
at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:104)
 at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
 at HiveJdbcClient.main(HiveJdbcClient.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.io.Writable
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
 at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 8 more

*Hive server logs the following message:*
mbj07@hadoop-test:~/workspace/hiveConnection/bin$ cat
/tmp/hduser/hive_job_log_hduser_201111041642_1329417361.txt
SessionStart SESSION_ID="hduser_201111041642" TIME="1320432162976"


I'd appreciate any help

Re: Problem running Hive Jdbc Client

Posted by Melchiades Blanco Junior <lu...@gmail.com>.
Thanks for replying Prasad.

[Shame on me] The problem has been solved.

I was following this tutorial :
https://cwiki.apache.org/confluence/display/Hive/HiveClient

And there is a script to run the HiveJdbcClient java aplication with the
following script:

#!/bin/bash
HADOOP_HOME=/your/path/to/hadoop
HIVE_HOME=/your/path/to/hive

echo -e '1\x01foo' > /tmp/a.txt
echo -e '2\x01bar' >> /tmp/a.txt
*HADOOP_CORE={{ls $HADOOP_HOME/hadoop-*-core.jar}}*
CLASSPATH=.:$HADOOP_CORE:$HIVE_HOME/conf
for i in ${HIVE_HOME}/lib/*.jar ; do
    CLASSPATH=$CLASSPATH:$i
done

java -cp $CLASSPATH HiveJdbcClient



The problem was setting the HADOOP_CORE var (bold remarked).
In the current version of Hadoop (0.20.203.0) the core file
is hadoop-core-0.20.203.0.jar.
So changing the script to *HADOOP_CORE={{ls
$HADOOP_HOME/hadoop-core-*.jar}} *would fix it.





On Fri, Nov 4, 2011 at 6:09 PM, Prasad Mujumdar <pr...@cloudera.com>wrote:

>
>      Do you have Hadoop jars in the classpath ?
>
> thanks
> Prasad
>
>
> On Fri, Nov 4, 2011 at 11:53 AM, Melchiades Blanco Junior <
> ludown@gmail.com> wrote:
>
>> Hey there, it's my first msg here. I'm trying to work with hive server by
>> connecting with its jdbc driver...
>>
>> I have already hadoop and hive cli working...
>>
>> I'm using this exemple of jdbc client:
>> https://cwiki.apache.org/confluence/display/Hive/HiveClient
>>
>> *When I run the script, I get the following message:*
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/hadoop/io/Writable
>> at
>> org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:196)
>>  at
>> org.apache.hadoop.hive.jdbc.HiveStatement.execute(HiveStatement.java:130)
>> at
>> org.apache.hadoop.hive.jdbc.HiveConnection.configureConnection(HiveConnection.java:107)
>>  at
>> org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveConnection.java:102)
>> at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:104)
>>  at java.sql.DriverManager.getConnection(DriverManager.java:582)
>> at java.sql.DriverManager.getConnection(DriverManager.java:185)
>>  at HiveJdbcClient.main(HiveJdbcClient.java:23)
>> Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.io.Writable
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
>>  at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>> ... 8 more
>>
>> *Hive server logs the following message:*
>> mbj07@hadoop-test:~/workspace/hiveConnection/bin$ cat
>> /tmp/hduser/hive_job_log_hduser_201111041642_1329417361.txt
>> SessionStart SESSION_ID="hduser_201111041642" TIME="1320432162976"
>>
>>
>> I'd appreciate any help
>>
>>
>

Re: Problem running Hive Jdbc Client

Posted by Prasad Mujumdar <pr...@cloudera.com>.
     Do you have Hadoop jars in the classpath ?

thanks
Prasad

On Fri, Nov 4, 2011 at 11:53 AM, Melchiades Blanco Junior
<lu...@gmail.com>wrote:

> Hey there, it's my first msg here. I'm trying to work with hive server by
> connecting with its jdbc driver...
>
> I have already hadoop and hive cli working...
>
> I'm using this exemple of jdbc client:
> https://cwiki.apache.org/confluence/display/Hive/HiveClient
>
> *When I run the script, I get the following message:*
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/hadoop/io/Writable
> at
> org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:196)
>  at
> org.apache.hadoop.hive.jdbc.HiveStatement.execute(HiveStatement.java:130)
> at
> org.apache.hadoop.hive.jdbc.HiveConnection.configureConnection(HiveConnection.java:107)
>  at
> org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveConnection.java:102)
> at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:104)
>  at java.sql.DriverManager.getConnection(DriverManager.java:582)
> at java.sql.DriverManager.getConnection(DriverManager.java:185)
>  at HiveJdbcClient.main(HiveJdbcClient.java:23)
> Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.io.Writable
> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
>  at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> ... 8 more
>
> *Hive server logs the following message:*
> mbj07@hadoop-test:~/workspace/hiveConnection/bin$ cat
> /tmp/hduser/hive_job_log_hduser_201111041642_1329417361.txt
> SessionStart SESSION_ID="hduser_201111041642" TIME="1320432162976"
>
>
> I'd appreciate any help
>
>