1

我不断收到同样的错误,我已经更改了指定 jaas 配置文件位置的 tomcat7w 文件

        javax.security.auth.login.LoginException: No LoginModules configured for    JaaSExample:
        at javax.security.auth.login.LoginContext.init(LoginContext.java:273)
    at javax.security.auth.login.LoginContext.<init>(LoginContext.java:514)
    at org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:417)
    at org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:356)
    at org.apache.catalina.realm.CombinedRealm.authenticate(CombinedRealm.java:146)
    at org.apache.catalina.realm.LockOutRealm.authenticate(LockOutRealm.java:180)
    at    org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:166)
    at  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:574)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

我已经将这个 tom 添加到我的 tomcat7w.exe 文件中。

    -Djava.security.auth.login.config=C:\Program Files (x86)\Apache Software                 Foundation\Tomcat 7.0\conf\jaas.config

还有就是我也有这个境界

    <Realm className="org.apache.catalina.realm.JAASRealm" 
    appName="JaaSExample"
    userClassNames="Security.UserPrincipal" roleClassNames="Security.RolePrincipal" />

所以我错过了什么?请帮我,

我正在使用netbeans,tomcat 7.0.47。

thank you very much,

我已决定使用 glassfish!

4

1 回答 1

2

根据http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#JAASRealm

您应该为 Java 设置 login.config 文件,并通过将其位置指定给 JVM 来告诉 Tomcat 在哪里找到它,例如通过设置环境变量:JAVA_OPTS=$JAVA_OPTS -Djava.security.auth.login.config=$CATALINA_BASE/conf/jaas.config

添加

对于 Windows 打开 startup.bat 添加以下行:set JAVA_OPTS=%JAVA_OPTS% -Djava.security.auth.login.config=%CATALINA_HOME%/conf/jaas.config after okHome

例如

set JAVA_OPTS=%JAVA_OPTS% -Djava.security.auth.login.config=%CATALINA_HOME%/conf/jaas.config
set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"
于 2013-11-11T13:30:00.263 回答