When I was configuring Hive 3.0.0 in Hadoop 3.2.1 environment, I encountered the following error:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
This issue happened because guava lib version is different in Hive lib folder and Hadoop shared folder.
To fix this, we need to ensure the versions are consistent.
Fix the issue
Follow these steps to fix it:
- Go to $HIVE_HOME (%HIVE_HOME%)/lib folder and find out the version of guava. For Hive 3.0.0, it is guava-19.0.jar.
- Go to $HADOOP_HOME (%HADOOP_HOME%)/share/hadoop/common/lib folder and out the version of guava. For Hadoop 3.2.1, the version is guava-27.0-jre.jar.
- If they are not same (which is true for this case), delete the older version and copy the newer version in both. In this case, delete guava-19.0.jar in Hive lib folder, and then copy guava-27.0-jre.jar from Hadoop folder to Hive.
If your Hive and Hadoop versions are not consistent, you may encounter other similar strange errors like this. The common approach to fix them is to make sure JAR file versions are the same. Typically if you align Hadoop and Hive versions, these issues wouldn't happen.