首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java - GSS initiate失败异常,原因: org.apache.thrift.transport.TTransportException: GSS initiate failed

Java - GSS initiate失败异常,原因: org.apache.thrift.transport.TTransportException: GSS initiate failed
EN

Stack Overflow用户
提问于 2018-03-20 21:57:52
回答 1查看 1.3K关注 0票数 0

我正在尝试从Hive表中检索记录。为此,我用Java编写了以下连接。

代码语言:javascript
复制
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;
    }
}

当我尝试在其他类中使用来自这个类的连接时,如下所示:

代码语言:javascript
复制
Connection hiveCon = (Connection) DbManager.getHiveConnection();
PreparedStatement hive_pstmnt =  hiveCon.prepareStatement(hiveCountQuery);
ResultSet hiveRs = hive_pstmnt.executeQuery();

我得到了一个异常:

代码语言:javascript
复制
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

在代码中,我注释了行: UserGroupInformation.setConfiguration(conf);如果我删除注释并执行代码,我会得到一个不同的异常:

代码语言:javascript
复制
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)

我做了kinit并生成了工单,只是为了确保工单有有效的时间段。谁能让我知道我在这里做的错误是什么,以便纠正代码。

EN

回答 1

Stack Overflow用户

发布于 2018-03-23 13:17:45

是kerberos的问题。票证不是在堡垒中生成的。一旦我创建了它,jar就成功运行了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49386237

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档