How to Fix Error: Unable to Instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
This tutorial demonstrates how to solve java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
.
Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
in Java
The Apache Hive is an open-source data warehouse software for reading, managing, and writing the large data sets stored in Hadoop files. It works similar to SQL; sometimes, if Hadoop and Hive are not configured properly, it can throw the error java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
.
The solution to this error while working on the Ubuntu platform is below. Follow the methods below to run the Hive shell properly without any errors.
the ~/.bashrc
File
Open the bashrc
file in the home directory and add the following environment variables at the end of the file sudo gedit ~/.bashrc
.
# directory configuration for JAVA_HOME
export JAVA_HOME="/usr/lib/jvm/java-9-oracle"
export PATH="$PATH:$JAVA_HOME/bin"
# directory configuration for HADOOP_HOME
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
export HIVE_HOME=/usr/lib/hive
export PATH=$PATH:$HIVE_HOME/bin
the .jar
File
We also need to put the .jar
file MySQL-connector-java-5.1.28.jar
or any latest version in the lib
directory of Hive home.
Create the hive-site.xml
File
We have to create the hive-site.xml
file, which will be placed in the conf
directory of Hive. Make sure to insert the following code in the file.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/metastore?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
<property>
<name>datanucleus.autoCreateSchema</name>
<value>true</value>
</property>
<property>
<name>datanucleus.fixedDatastore</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateTables</name>
<value>True</value>
</property>
</configuration>
Install the Required Software and Plugins
To run the Hive shell on Ubuntu, we must install a few software first. The list is given below.
- MySQL
- Hadoop
- Hive
- Java
Once this software and plugins are successfully installed, we can run the Hive shell.
Execute Services and Run Hive Shell
The final method is the execution part, where we need to execute all the services and run the Hive shell. Follow the steps below.
- Start all Hadoop’s services by starting
start-all.sh
. - Now check if all the services of Hadoop are running. Use the
jps
command to check that. - Finally, enter the Hive command to start the Hive shell.
Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.
LinkedIn FacebookRelated Article - Java Error
- How to Fix the Error: Failed to Create the Java Virtual Machine
- How to Fix the Missing Server JVM Error in Java
- How to Fix the 'No Java Virtual Machine Was Found' Error in Eclipse
- How to Fix Javax.Net.SSL.SSLHandShakeException: Remote Host Closed Connection During Handshake
- How to Fix the Error: Failed to Create the Java Virtual Machine
- How to Fix Java.Lang.VerifyError: Bad Type on Operand Stack