Reputation: 2962
I am not able to launch Hive while following the getting started procedure
Here is the error:
$ ./hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoopuser/Downloads/apache-hive-3.1.2-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoopuser/hadoop-2.8.5/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]
Hive Session ID = 3494229b-6c3c-4c5b-ba62-a82edde75f18
Exception in thread "main" java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:413)
at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:389)
at org.apache.hadoop.hive.cli.CliSessionState.<init>(CliSessionState.java:60)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:705)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683)
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:566)
at org.apache.hadoop.util.RunJar.run(RunJar.java:239)
at org.apache.hadoop.util.RunJar.main(RunJar.java:153)
I believe the problem is coming from the java version, based on other SO questions. But they did not help me.
When I run java -version
, I get:
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)
However, when I get my $JAVA_HOME variable, it is correctly set to java 1.8:
$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-amd64
BUT, when I use the alternative command to select my java version, I get the following result:
$ sudo update-alternatives --config java
[sudo] password for hadoopuser:
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
* 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
What am I doing wrong?
Edit 1 : Similar error when running ./beeline -u jdbc:hive2://
Upvotes: 2
Views: 2939
Reputation: 8670
For exactly same problem with Hadoop version 3.3.5 and Hive 3.1.3. on Ubuntu 22.04, I have to install JDK with below command
sudo apt install openjdk-8-jdk
and Then set JAVA_HOME as follows
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
export PATH="/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH"
Below option does not fix the issue for me
export PATH="/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin:$PATH"
Upvotes: 2
Reputation: 151
It might be that the binaries for Java 11 are still first in your PATH. Check if the bin folder for Java 11 is appearing first with echo $PATH
.
If that's the case, a quick fix might just be to prepend the path to the Java 8 bin folder to your .bashrc
file. Appending something like this might help:
export PATH="/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin:$PATH"
Then java -version
should show the right one.
Upvotes: 4