简体   繁体   English

Java-GSS启动失败异常,由以下原因引起:org.apache.thrift.transport.TTransportException:GSS启动失败

[英]Java - GSS initiate failed Exception, Caused by: org.apache.thrift.transport.TTransportException: GSS initiate failed

I am trying to retrieve records from the Hive tables. 我正在尝试从Hive表中检索记录。 For that I have written the following connection in Java. 为此,我用Java编写了以下连接。

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;
    }
}

When I try to use the connection from this class, in other class like below: 当我尝试使用此类中的连接时,在如下所示的其他类中:

Connection hiveCon = (Connection) DbManager.getHiveConnection();
PreparedStatement hive_pstmnt =  hiveCon.prepareStatement(hiveCountQuery);
ResultSet hiveRs = hive_pstmnt.executeQuery();

I am getting the exception: 我得到了例外:

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

In the code, I have commented the line: UserGroupInformation.setConfiguration(conf); 在代码中,我注释了以下行:UserGroupInformation.setConfiguration(conf); and if I remove the comments and execute the code, I get a different exception: 如果删除注释并执行代码,则会得到另一个异常:

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)

I have done kinit and generated the ticket just to make sure the ticket has valid time period. 我已经完成了kinit并生成了票证,只是为了确保票证有有效的时间段。 Could anyone let me know what is the mistake I am doing here so that can correct the code. 谁能让我知道我在这里做的错误是什么,以便可以更正代码。

It was kerberos issue. 这是kerberos的问题。 The ticket was not generated in the bastion. 票证不是在堡垒中生成的。 Once I created it, the jar ran successfully. 创建完后,罐子成功运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 钻探到Hive连接错误(org.apache.thrift.transport.TTransportException java.net.SocketException:管道断开(写入失败)) - Drill to Hive connectivity error(org.apache.thrift.transport.TTransportException java.net.SocketException: Broken pipe (Write failed)) 可以通过beeline连接到hive,但不能通过java连接。 错误无法使用JDBC Uri GSS启动客户端打开客户端传输失败 - Can connect to hive through beeline, but not java. Error Could not open client transport with JDBC Uri GSS initiate failed java.sql.SQLException:Hive中的org.apache.thrift.transport.TTransportException吗? - java.sql.SQLException: org.apache.thrift.transport.TTransportException in hive? TThreadPoolServer客户端org.apache.thrift.transport.TTransportException:java.net.SocketException:管道损坏 - TThreadPoolServer Clients org.apache.thrift.transport.TTransportException: java.net.SocketException: Broken pipe java.sql.SQLNonTransientConnectionException:org.apache.thrift.transport.TTransportException:帧大小大于最大长度(16384000)! - java.sql.SQLNonTransientConnectionException: org.apache.thrift.transport.TTransportException: Frame size larger than max length (16384000)! org.apache.thrift.transport.TTransportException:读取负帧大小(-2080374784)! - org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)! 使用 Java 中的 JDBC HiveDriver 连接到启用 Kerberos 的集群时出错。 javax.security.sasl.SaslException:GSS 启动失败 - Error connecting to Kerberos enabled cluster using JDBC HiveDriver in Java. javax.security.sasl.SaslException: GSS initiate failed 线程“ main”中的异常java.lang.NoClassDefFoundError:org / apache / thrift / transport / TTransportException - Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/thrift/transport/TTransportException 闲置一分钟后运行第二个查询时,hiveserver2 org.apache.thrift.transport.TTransportException错误 - hiveserver2 org.apache.thrift.transport.TTransportException error when running 2nd query after minute of inactivity TTransportException使用Apache Thrift时发生异常 - TTransportException Exception while working with Apache Thrift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM