描述:我构建了一个应用程序,它从应用了Kerberos身份验证的远程群集中获取HDFS(Hadoop分布式文件系统)文件。我可以从Eclipse执行HDFS.copyToLocalFile(path1,path2)并且工作正常。但是当我将项目导出为可运行的jar并尝试通过命令行运行时,它会抛出以下错误。注意:我遵循了@ https://sourceforge.net/p/jsch/mailman/message/26939797/中提到的步骤,并成功地从Eclipse运行项目。我已经在Eclipse中检查了其他文件,但找不到任何文件。我安装了Kerberos V5 MIT以及Network Identity Manager(4.0版本)
Caused by: java.io.IOException: org.apache.hadoop.security.AccessControlException: Client cannot authenticate via:[TOKEN, KERBEROS]
at org.apache.hadoop.ipc.Client$Connection$1.run(Client.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Unknown Source)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
at org.apache.hadoop.ipc.Client$Connection.handleSaslConnectionFailure(Client.java:643)
at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:730)
at org.apache.hadoop.ipc.Client$Connection.access$2800(Client.java:368)
at org.apache.hadoop.ipc.Client.getConnection(Client.java:1521)
at org.apache.hadoop.ipc.Client.call(Client.java:1438)
... 70 more
Caused by: org.apache.hadoop.security.AccessControlException: Client cannot authenticate via:[TOKEN, KERBEROS]
at org.apache.hadoop.security.SaslRpcClient.selectSaslClient(SaslRpcClient.java:172)
at org.apache.hadoop.security.SaslRpcClient.saslConnect(SaslRpcClient.java:396)
at org.apache.hadoop.ipc.Client$Connection.setupSaslConnection(Client.java:553)
at org.apache.hadoop.ipc.Client$Connection.access$1800(Client.java:368)
at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:722)
at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:718)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Unknown Source)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:717)
... 73 more
注意:我已将重叠的相关参数配置到Configuration.xml中,并将其捆绑到类路径中。
<property>
<name>java.security.auth.login.config</name>
<value>./Configuration/login.conf</value>
</property>
<property>
<name>java.security.krb5.conf</name>
<value>./Configuration/krb5.conf</value>
</property>
<property>
<name>javax.security.auth.useSubjectCredsOnly</name>
<value>false</value>
</property>
答案 0 :(得分:1)
我认为Kerberos身份验证失败,因为在使用JAR时无法在运行时找到login.conf
和krb5.conf
文件。
当我尝试从JAR文件访问assets
文件夹中的文件时,我遇到了类似的问题。关键是,在将包导出为JAR时,路径会以某种方式发生变化。您是否有机会以某种方式检查代码中的文件路径,例如
String resourceFile = YourClass.class.getResource("/krb5.conf").getFile();
// check if resourceFile is null!
如果此class.getResource(...)
命令适用于通过IDE运行,但不会在JAR中运行,则问题在于文件位置的差异。
我认为这篇文章可以帮到你:How to get a path to a resource in a Java JAR file