hive shell not starting

2019-08-14 13:19发布

问题:

    hadoop_1@shubho-HP-Notebook:~$ hive
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/home/hadoop_1/apache-hive-2.3.2-bin/lib           /log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop_1/hadoop/share/hadoop/common       /lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader
    at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:394)
    at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:370)
    at org.apache.hadoop.hive.cli.CliSessionState.<init>(CliSessionState.java:60)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:708)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:686)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
hadoop_1@shubho-HP-Notebook:~$

The above Exception was thrown. So I checked and there was no conf/hive-site.xml. So I created and edited it:

<property>
  <name>hive.exec.local.scratchdir</name>
    <value>$HIVE_HOME/iotmp</value>
    <description>Local scratch space for Hive jobs</description>
</property>
<property>
   <name>hive.querylog.location</name>
    <value>$HIVE_HOME/iotmp</value>
    <description>Location of Hive run time structured log file</description>
 </property>
 <property>
   <name>hive.downloaded.resources.dir</name>
    <value>$HIVE_HOME/iotmp</value>
    <description>Temporary local directory for added resources in the remote file system.</description>
 </property>

Still the same error is thrown.

回答1:

I was struggling with the same error. I found that the problem was caused because I installed java 9 and configured hadoop with java 9. While Hive does not support java version 9.

The solution is to replace java version 9 with java version 8.Install java version 8 and then configure both hadoop and hive on java 8.

Open file $HADOOP_HOME/etc/hadoop/hadoop-env.sh and paste the below line:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

also set the same address while configuring hive.



回答2:

I was face same problem , hive sell is not start when type command hive.first, I was Check all daemons are running or not using jps command , in my case namenode is not working.so first stop all running daemons use stop-all.sh then format namenode (namenode -format) and again start by start-all.sh then check it using jps.If the problem is still remain you can check your configuration files and confg again , it was work for me.