<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Java - GSS initiate failed Exception, Caused by: org.apache.thrift.transport.TTransportException: GS in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-GSS-initiate-failed-Exception-Caused-by-org-apache/m-p/65590#M76144</link>
    <description>&lt;P&gt;I am trying to retrieve records from the Hive tables. For that I have written the following connection in Java.&lt;/P&gt;&lt;PRE&gt;public static Connection getHiveConnection() throws IOException, SQLException {
    System.out.println("Preparing Hive connection1");
    Configuration conf = new Configuration();
    conf.set("hadoop.security.authentication", "Kerberos");

    System.setProperty("java.security.krb5.kdc", "ip-x-x-x-x.bc9.internal");
    System.setProperty("java.security.krb5.realm", "ABCDEV.COM");
    UserGroupInformation.loginUserFromKeytab("username@ABCDEV.COM", "/home/username/username.keytab");
    // UserGroupInformation.setConfiguration(conf);
    System.out.println("Kerberos Connected");
    // Hive Connection
    try {
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        if((hiveConnection == null) || hiveConnection.isClosed()) {
            hiveConnection = DriverManager.getConnection("jdbc:hive2://x.x.x.x.x:10500/schema;principal=hive/_HOST@ABCDEV.COM", "user", "pwd");
            return hiveConnection;
        } else {
        return hiveConnection;
        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        return null;
    } catch (SQLException e) {
        e.printStackTrace();
        return null;
    }
}&lt;/PRE&gt;&lt;P&gt;When I try to use the connection from this class, in other class like below:&lt;/P&gt;&lt;PRE&gt;Connection hiveCon = (Connection) DbManager.getHiveConnection();
PreparedStatement hive_pstmnt =  hiveCon.prepareStatement(hiveCountQuery);
ResultSet hiveRs = hive_pstmnt.executeQuery();&lt;/PRE&gt;&lt;P&gt;I am getting the exception:&lt;/P&gt;&lt;PRE&gt;Preparing Hive connection1
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Kerberos Connected
java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://x.x.x.x.x:10500/schema;principal=hive/_HOST@ABCDEV.COM: GSS initiate failed
Caused by: org.apache.thrift.transport.TTransportException: GSS initiate failed&lt;/PRE&gt;&lt;P&gt;In the code, I have commented the line: UserGroupInformation.setConfiguration(conf); and if I remove the comments and execute the code, I get a different exception:&lt;/P&gt;&lt;PRE&gt;Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.IllegalArgumentException: Invalid attribute value for hadoop.security.authentication of Kerberos
        at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:200)
        at org.apache.hadoop.security.UserGroupInformation.setConfiguration(UserGroupInformation.java:227)
        at com.dbconnections.gphive.DbManager.getHiveConnection(DbManager.java:24)&lt;/PRE&gt;&lt;P&gt;I have done kinit and generated the ticket just to make sure the ticket has valid time period. Could anyone let me know what is the mistake I am doing here so that can correct the code.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 12:59:51 GMT</pubDate>
    <dc:creator>Sidhartha</dc:creator>
    <dc:date>2022-09-16T12:59:51Z</dc:date>
    <item>
      <title>Java - GSS initiate failed Exception, Caused by: org.apache.thrift.transport.TTransportException: GS</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-GSS-initiate-failed-Exception-Caused-by-org-apache/m-p/65590#M76144</link>
      <description>&lt;P&gt;I am trying to retrieve records from the Hive tables. For that I have written the following connection in Java.&lt;/P&gt;&lt;PRE&gt;public static Connection getHiveConnection() throws IOException, SQLException {
    System.out.println("Preparing Hive connection1");
    Configuration conf = new Configuration();
    conf.set("hadoop.security.authentication", "Kerberos");

    System.setProperty("java.security.krb5.kdc", "ip-x-x-x-x.bc9.internal");
    System.setProperty("java.security.krb5.realm", "ABCDEV.COM");
    UserGroupInformation.loginUserFromKeytab("username@ABCDEV.COM", "/home/username/username.keytab");
    // UserGroupInformation.setConfiguration(conf);
    System.out.println("Kerberos Connected");
    // Hive Connection
    try {
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        if((hiveConnection == null) || hiveConnection.isClosed()) {
            hiveConnection = DriverManager.getConnection("jdbc:hive2://x.x.x.x.x:10500/schema;principal=hive/_HOST@ABCDEV.COM", "user", "pwd");
            return hiveConnection;
        } else {
        return hiveConnection;
        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        return null;
    } catch (SQLException e) {
        e.printStackTrace();
        return null;
    }
}&lt;/PRE&gt;&lt;P&gt;When I try to use the connection from this class, in other class like below:&lt;/P&gt;&lt;PRE&gt;Connection hiveCon = (Connection) DbManager.getHiveConnection();
PreparedStatement hive_pstmnt =  hiveCon.prepareStatement(hiveCountQuery);
ResultSet hiveRs = hive_pstmnt.executeQuery();&lt;/PRE&gt;&lt;P&gt;I am getting the exception:&lt;/P&gt;&lt;PRE&gt;Preparing Hive connection1
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Kerberos Connected
java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://x.x.x.x.x:10500/schema;principal=hive/_HOST@ABCDEV.COM: GSS initiate failed
Caused by: org.apache.thrift.transport.TTransportException: GSS initiate failed&lt;/PRE&gt;&lt;P&gt;In the code, I have commented the line: UserGroupInformation.setConfiguration(conf); and if I remove the comments and execute the code, I get a different exception:&lt;/P&gt;&lt;PRE&gt;Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.IllegalArgumentException: Invalid attribute value for hadoop.security.authentication of Kerberos
        at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:200)
        at org.apache.hadoop.security.UserGroupInformation.setConfiguration(UserGroupInformation.java:227)
        at com.dbconnections.gphive.DbManager.getHiveConnection(DbManager.java:24)&lt;/PRE&gt;&lt;P&gt;I have done kinit and generated the ticket just to make sure the ticket has valid time period. Could anyone let me know what is the mistake I am doing here so that can correct the code.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 12:59:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-GSS-initiate-failed-Exception-Caused-by-org-apache/m-p/65590#M76144</guid>
      <dc:creator>Sidhartha</dc:creator>
      <dc:date>2022-09-16T12:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Java - GSS initiate failed Exception, Caused by: org.apache.thrift.transport.TTransportException</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-GSS-initiate-failed-Exception-Caused-by-org-apache/m-p/65598#M76145</link>
      <description>&lt;P&gt;The error complains about the value of "hadoop.security.authentication". You have set it to "Kerberos" while the accepted values are "simple" and "kerberos" (all letters in lowercase).&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 15:11:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-GSS-initiate-failed-Exception-Caused-by-org-apache/m-p/65598#M76145</guid>
      <dc:creator>GeKas</dc:creator>
      <dc:date>2018-03-20T15:11:13Z</dc:date>
    </item>
  </channel>
</rss>

