Java 找不到LoginModule类:com.sun.security.auth.module.UnixLoginModule

Java 找不到LoginModule类:com.sun.security.auth.module.UnixLoginModule,java,security,hadoop,authentication,kerberos,Java,Security,Hadoop,Authentication,Kerberos,试图使用Kerberose身份验证访问HDFS位置,但收到以下错误消息: java.io.IOException: failure to login at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:839) at org.apache.hadoop.security.UserGroupInformation.getLo

试图使用Kerberose身份验证访问HDFS位置,但收到以下错误消息:

java.io.IOException: failure to login
        at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:839)
        at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:775)
        at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:648)
        at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2859)
        at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2851)
        at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2714)
        at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:382)
        at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:181)
        at com.xyz.module.submodule.common.utils.HDFSPropertyLookup.loadProperties(HDFSPropertyLookup.java:75)
        at com.xyz.module.submodule.common.utils.HDFSPropertyLookup.initialize(HDFSPropertyLookup.java:37)
        at com.xyz.module.submodule.common.utils.HDFSPropertyLookupTest.initializePropertiesFile(HDFSPropertyLookupTest.java:16)
        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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: javax.security.auth.login.LoginException: unable to find LoginModule class: com.sun.security.auth.module.UnixLoginModule
        at javax.security.auth.login.LoginContext.invoke(LoginContext.java:794)
        at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
        at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
        at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
        at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
        at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:813)
        ... 31 more
java.io.IOException:登录失败
位于org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:839)
位于org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:775)
位于org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:648)
位于org.apache.hadoop.fs.FileSystem$Cache$Key.(FileSystem.java:2859)
位于org.apache.hadoop.fs.FileSystem$Cache$Key.(FileSystem.java:2851)
位于org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2714)
位于org.apache.hadoop.fs.FileSystem.get(FileSystem.java:382)
位于org.apache.hadoop.fs.FileSystem.get(FileSystem.java:181)
位于com.xyz.module.submodule.common.utils.HDFSPropertyLookup.loadProperties(HDFSPropertyLookup.java:75)
位于com.xyz.module.submodule.common.utils.HDFSPropertyLookup.initialize(HDFSPropertyLookup.java:37)
位于com.xyz.module.submodule.common.utils.HDFSPropertyLookupTest.InitializeProperties文件(HDFSPropertyLookupTest.java:16)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中
位于java.lang.reflect.Method.invoke(Method.java:498)
位于org.junit.runners.model.FrameworkMethod$1.runReflectVeCall(FrameworkMethod.java:50)
位于org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
位于org.junit.runners.model.FrameworkMethod.invokeeexplosive(FrameworkMethod.java:47)
位于org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
位于org.junit.runners.ParentRunner.run(ParentRunner.java:363)
位于org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
位于org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
位于org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中
位于java.lang.reflect.Method.invoke(Method.java:498)
位于org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
位于org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
位于org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
位于org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
位于org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
原因:javax.security.auth.login.login异常:找不到LoginModule类:com.sun.security.auth.module.UnixLoginModule
位于javax.security.auth.login.LoginContext.invoke(LoginContext.java:794)
位于javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
位于javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
位于javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
位于java.security.AccessController.doPrivileged(本机方法)
位于javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
位于javax.security.auth.login.LoginContext.login(LoginContext.java:587)
位于org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:813)
... 还有31个
原因:
LoginModule类:com.sun.security.auth.module.unixlogimodule
未找到

想知道哪个
.jar
文件
com.sun.security.auth.module.unixlogimodule
存在吗


如果有人以前可能遇到过这个问题,那么请让我帮忙

这个问题解决了

让我谈谈真正的原因,以及它是如何解决的

在单元测试代码中,我为我的测试用例场景将
os.name
system属性值设置为不同的操作系统,如下所示:

System.setProperty("os.name", "Windows");
我用Windows/Unix/MAC等设置了上述属性值,但没有重置为其原始值

在同一个项目中,我正在执行
FileSystem.get(newconfiguration())来自Hadoop API,其中设置了Kerberose身份验证

所以,当执行时,操作系统名称被更改为其他名称,并且没有重置为原始名称

解决方案:

因此,在setup方法中,我将原始OS名称收集到其他变量中,并在所有测试用例完成后重置为原始名称,如下所示:

@BeforeClass
public static void setup() throws IOException {
    System.setProperty("os.name.orig", System.getProperty("os.name"));

}

// other test case methods continue...

@AfterClass
public static void clearProperties() throws IOException {
    System.setProperty("os.name", System.getProperty("os.name.orig"));
    System.clearProperty("os.name.orig");
}
在上述设置之后,操作系统恢复到原来的名称,一切都开始正常工作


希望这将有助于其他人在未来

缺少的jar是rt.jar。它的from jre/librt.jar位于C:\Program Files\Java\jdk1.8.0_152\jre\lib\rt.jar进入项目上的配置构建路径,进入“库”选项卡,然后进入“系统库”,然后使用eclipse检查rt.jar,它正在我的机器上运行,但在命令提示符下它没有运行。发布pom.xmlNice作业。请自己接受你自己的答案。你可能会被迫等待两天,以便让自我接受,但这将有助于更好地向在谷歌上搜索这个问题的人提示这个问题。