0

I am trying to connect to hive from my local java application using JDBC driver but am getting an error:

Exception in thread "main" java.sql.SQLException: Could not open client transport with JDBC Uri: <url>: GSS initiate failed

Code snippet:

org.apache.hadoop.conf.Configuration conf = new 
org.apache.hadoop.conf.Configuration();
conf.set("hadoop.security.authentication", "Kerberos");
UserGroupInformation.setConfiguration(conf);
UserGroupInformation.loginUserFromKeytab("principal", "keytab_location");
Class.forName("org.apache.hive.jdbc.HiveDriver");
Connection conn = DriverManager.getConnection(url);

I am fairly new to this so I apologize in advance if this is a stupid question, but how can I specify the krb5.conf location or to simply use what is in the credentials cache?

I have tried to set system properties but that did not work either:

System.setProperty("java.security.krb5.conf", "krb5_location");

Any help is greatly appreciated. Thanks!

  • _"local java app"_ > Linux or Windows? Any warning about missing "native libs" when dealing with `UserGroupInformation`? – Samson Scharfrichter Aug 24 '18 at 07:02
  • Check my answer to https://stackoverflow.com/questions/42477466/error-when-connect-to-impala-with-jdbc-under-kerberos-authrication/42506620 for _(1)_ the debugging flags that will show you at which point Kerberos had failed silently, and _(2)_ a way to bypass the `UsetGroupInformation` -- I would also advise you to use the Cloudera driver (based on a commercial SDK) that has better JDBC compliance and does not have so many silly dependencies to Hadoop jars. – Samson Scharfrichter Aug 24 '18 at 07:10
  • I have read that the Cloudera version is better but I am limited to the Hortonworks distribution (this is for work). I will take a look at your answer in the other post. Appreciate the help No warnings about missing libs for usergroupinformation either – ougabouga Aug 24 '18 at 14:09
  • @SamsonScharfrichter I have followed the steps from your other post and it seems to pick up the Kerberos username, but it is asking for the password. I was under the impression that the keytab should circumvent the need for a password. Regardless, after inputting my password, it gives me the same GSS Initiate Failed error. Any help is greatly appreciated! – ougabouga Aug 24 '18 at 16:47

0 Answers0