问题 mvn jetty:运行找不到我的LoginService


我按如下方式建立了一个码头安全领域(与mvn jetty:run一起使用)。 这工作:

的pom.xml

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <configuration>
      <webAppXml>src/test/resources/jetty-test.xml</webAppXml>
      <useTestScope>true</useTestScope>
    </configuration>
  </plugin>

码头-的test.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Get name="securityHandler">
    <Set name="loginService">
      <New class="org.eclipse.jetty.security.HashLoginService">
        <Set name="name">MySecurityRealm</Set>
        <Set name="config">src/test/resources/jetty-realm.properties</Set>
        <Call name="start"/>
      </New>
    </Set>
    <Set name="checkWelcomeFiles">true</Set>
  </Get>
</Configure>

的pom.xml

然后我尝试删除对jetty-test.xml文件的需要,如下所示。

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <configuration>
   <!--      <webAppXml>src/test/resources/jetty-test.xml</webAppXml>  -->
          <useTestScope>true</useTestScope>
          <loginServices>
            <loginService implementation="org.eclipse.jetty.security.HashLoginService">
              <name>MySecurityRealm</name>
              <config>${basedir}/src/test/resources/jetty-realm.properties</config>
            </loginService>
          </loginServices>
        </configuration>
      </plugin>

但它失败了:

2013-03-26 16:33:26.197:WARN:oejuc.AbstractLifeCycle:FAILED org.eclipse.jetty.security.ConstraintSecurityHandler@73937bc8: java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.BasicAuthenticator@3d47dde in org.eclipse.jetty.security.ConstraintSecurityHandler@73937bc8

任何想法?

我正在使用这个文档: http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin#Configuring_Security_Settings


4308
2018-03-26 15:42


起源



答案:


请验证是否有子元素 <name>MySecurityRealm</name> 对于 <loginServices> 在你的jetty-maven-plugin配置中是一样的 <realm-name>MySecurityRealm</realm-name> 对于 <login-config> 在你的web.xml中。


9
2017-07-03 07:40



这个答案解决了我的问题,非常感谢! - John the Traveller


答案:


请验证是否有子元素 <name>MySecurityRealm</name> 对于 <loginServices> 在你的jetty-maven-plugin配置中是一样的 <realm-name>MySecurityRealm</realm-name> 对于 <login-config> 在你的web.xml中。


9
2017-07-03 07:40



这个答案解决了我的问题,非常感谢! - John the Traveller


您的web.xml中可能存在安全性约束: 参考。这就是当你注释掉jetty-test.xml配置时失败的原因。


1
2018-04-24 18:55