我正在尝试从java程序执行配置单元查询,为此,我在oozie工作流中使用oozie java操作。我使用下面的代码片段来做这个。这似乎是失败的。但是,如果我使用shell操作执行此代码,它就可以正常工作。我需要帮助理解我做错了什么。使用keytab文件不是一个选项,必须使用delegationtoken。
public static Connection createConnection(String url) {
Properties props = new Properties();
props.put("auth", "delegationToken");
Configuration conf = new Configuration();
conf.set("hadoop.security.authentication", "Kerberos");
UserGroupInformation.setConfiguration(conf);
try {
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
if (connection == null || connection.isClosed()) {
connection = (Connection)ugi.doAs(new PrivilegedExceptionAction<Object>() {
public Object run() {
Connection con = null;
try {
Class.forName("org.apache.hive.jdbc.HiveDriver");
con = DriverManager.getConnection(url, props);
} catch (Exception ex)
throw new IllegalStateException(errMsg, e);
}
return con;
}
});
}
} catch (Exception ex) {
throw new IllegalStateException(errMsg, ex);
}
return connection;
}
错误:
失败的oozie启动程序,main类[org.apache.oozie.action.hadoop.javamain],main()引发异常,java.lang.illegalstateexception:获取配置单元jdbc连接org.apache.oozie.action.hadoop.javamainexception:java.lang.illegalstateexception:获取配置单元jdbc连接org.apache.oozie.action.hadoop.javamain.run(javamain)时出错。java:58)在org.apache.oozie.action.hadoop.launchemain.run(launchemain。java:81)在org.apache.oozie.action.hadoop.javamain.main(javamain。java:35)在sun.reflect.nativemethodaccessorimpl.invoke0(本机方法)在sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl)。java:62)在sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl。java:43)在java.lang.reflect.method.invoke(方法。java:498) 在org.apache.oozie.action.hadoop.launchermapper.map(launchermapper。java:235)在org.apache.hadoop.mapred.maprunner.run(maprunner。java:54)在org.apache.hadoop.mapred.maptask.runoldmapper(maptask。java:459)在org.apache.hadoop.mapred.maptask.run(maptask。java:343)在org.apache.hadoop.mapred.yarnchild$2.run(yarnchild。java:164)在javax.security.auth.subject.doas(主题)中的java.security.accesscontroller.doprivileged(本机方法)。java:422)在org.apache.hadoop.security.usergroupinformation.doas(usergroupinformation。java:1924)在org.apache.hadoop.mapred.yarnchild.main(yarnchild。java:158)
暂无答案!
目前还没有任何答案,快来回答吧!