FAILED: HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

I think Hive expect to find Derby database in current working directory. Hive will create the database, because create=true in javax.jdo.option.ConnectionURL property, but will not initialize schema in the database.

My configuration:

  • Ubuntu 18.04.1 LTS
  • Hadoop 3.1.1
  • Hive 3.1.0
  • Apache Derby from Ubuntu repositories (Version: 10.14.1.0-1ubuntu1 currently)

    sudo apt install derby-tools libderby-java libderbyclient-java

According Hive Documentation we need to run ShemaTool explicity.

I decide to keep my Derby database into HIVE_HOME (/opt/hive-3.1.0-bin in my case) directory. You can setup Derby database location in hive-site.xml:

<property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:derby:/opt/hive-3.1.0-bin/metastore_db;databaseName=metastore_db;create=true</value>
</property>

Ensure that there is no Derby database yet:

$ ls $HIVE_HOME/meta*
ls: cannot access '/opt/hive-3.1.0-bin/meta*': No such file or directory

Start Hive:

$ pwd
/home/hadoop
$ hive
hive> show tables;
FAILED: HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
hive> exit;

Now we got Derby database, but it's not functional:

$ ls -d $HIVE_HOME/meta*
/opt/hive-3.1.0-bin/metastore_db

So, we need to create metada schema:

$ rm -rf $HIVE_HOME/metastore_db
$ cd $HIVE_HOME
$ schematool -initSchema -dbType derby
...
Initialization script completed
schemaTool completed

Now Hive is working as expected:

$ cd
$ hive
hive> show tables;
OK
Time taken: 0.803 seconds