Hive初始化报错Exception in thread “main“ java.lang.NoSuchMethodError: com.google.common.base.Precondition
Posted Nan YI I
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hive初始化报错Exception in thread “main“ java.lang.NoSuchMethodError: com.google.common.base.Precondition相关的知识,希望对你有一定的参考价值。
Hive 3.1.3 在执行初始化配置命令
bin/schematool -dbType derby -initSchema
的时候报下方错误
[root@hadoop100 hive-3.1.3]# bin/schematool -dbType derby -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/hive-3.1.3/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357)
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338)
at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:518)
at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:536)
at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:430)
at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5144)
at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5107)
at org.apache.hive.beeline.HiveSchemaTool.<init>(HiveSchemaTool.java:96)
at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1473)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:318)
at org.apache.hadoop.util.RunJar.main(RunJar.java:232)
这是因为hadoop和hive的两个guava.jar版本不一致,解决方案:
删除低版本的那个,将高版本的复制到低版本目录下
- 第一步:查看hive3.1.3里的guava.jar
这个保存在hive的lib里,比如我的就在这个目录里面:
/opt/module/hive-3.1.3/lib
版本是 guava-19.0.jar
- 第二步:查看hadoop3.1.3 里的guava.jar
这个保存在hadoop3.1.3的这个目录里面:
/opt/module/hadoop-3.1.3/share/hadoop/common/lib
- 第三步:对比hive3.1.3里面和hadoop3.1.3里面guava的版本,统一换成高版本
- 第四步:将hive3.1.3里面guava的版本,换成hadoop3.1.3里面的高版本即可
# 将hive3.1.3里面的guava重命名即可,不需要删除
mv guava-19.0.jar guava-19.0.jar_bak
# 将hadoop3.1.3里面的guava拷贝到hive3.1.3里面一份
cp /opt/module/hadoop-3.1.3/share/hadoop/common/lib/guava-27.0-jre.jar
- 第五步:重新执行初始化命令
[root@hadoop100 hive-3.1.3]# bin/schematool -dbType derby -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/hive-3.1.3/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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]
Metastore connection URL: jdbc:derby:;databaseName=metastore_db;create=true
Metastore Connection Driver : org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User: APP
Starting metastore schema initialization to 3.1.0
Initialization script hive-schema-3.1.0.derby.sql
Initialization script completed
schemaTool completed
[root@hadoop100 hive-3.1.3]#
以上是关于Hive初始化报错Exception in thread “main“ java.lang.NoSuchMethodError: com.google.common.base.Precondition的主要内容,如果未能解决你的问题,请参考以下文章
启动hive错误:Exception in thread "main" java.lang.IllegalArgumentException
SparkSpark cache 报错 Exception thrown in awaitResult
java servlet PrintWriter #flush stop thr Exception
Exception in thread main org.apache.ibatis.exceptions.PersistenceException:报错解决
Unity2021打包报错: Exception: OBSOLETE - Providing Android resources in Assets/Plugins/Android/
java使用类数组 报错Exception in thread "main" java.lang.NullPointerException