TKh TKh - 1 month ago 21
Java Question

Hive JDBC Kerberose Authentication Error: GSS initiate failed

I am trying to connect to Hive through JDBC using the following connection string:

Class.forName("org.apache.hive.jdbc.HiveDriver")

hiveConString = "jdbc:hive2://localhost:10000/default;principal=hive/_HOST@HADOOP.LOCALDOMAIN"


Though I encounter the following error:

Exception in thread "main" java.sql.SQLException: Could not open client transport with JDBC Uri:jdbc:hive2://localhost:10000/default;principal=hive/_HOST@HADOOP.LOCALDOMAIN:GSS initiate failed


I already checked the hive-site.xml to ensure that kerbersoe authentication is followed. The XML file includes:

<property>
<name>hive.server2.authentication.kerberos.principal</name>
<value>hive/_HOST@HADOOP.LOCALDOMAIN</value>
</property>


I have also made sure that all of the required Maven repositories are included.

Also, I am running the code on a VM using Eclipse.

Answer

If using a VM with kerberos authentication and your authentication has not expired you will need to specify the following VM arguments when running your java code:

-Djava.security.krb5.debug=true 
-Djava.security.krb5.conf="/etc/krb5.conf"
-Djavax.security.auth.useSubjectCredsOnly=false