java mvn jetty:run 找不到我的 LoginService

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15641263/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 20:22:27  来源:igfitidea点击:

mvn jetty:run does not find my LoginService

javajetty

提问by David Portabella

I set-up a jetty security realm as follows (to be used with mvn jetty:run). this works:

我按如下方式设置了一个码头安全领域(与 一起使用mvn jetty:run)。这有效:

pom.xml

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>

jetty-test.xml

jetty-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>

then I try to remove the need for the jetty-test.xmlfile, as follows:

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

pom.xml

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>
          <loginServices>
            <loginService implementation="org.eclipse.jetty.security.HashLoginService">
              <name>MySecurityRealm</name>
              <config>${basedir}/src/test/resources/jetty-realm.properties</config>
            </loginService>
          </loginServices>
        </configuration>
      </plugin>

but it fails with:

但它失败了:

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

Any idea?

任何的想法?

I am using this documentation: http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin#Configuring_Security_Settings

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

回答by Conny Krey?el

Please verify if sub-element <name>MySecurityRealm</name>for <loginServices>in your jetty-maven-plugin configuration is the same as <realm-name>MySecurityRealm</realm-name>for <login-config>in your web.xml.

请确认如果子元素<name>MySecurityRealm</name><loginServices>您的码头- Maven的插件配置是一样<realm-name>MySecurityRealm</realm-name><login-config>在你的web.xml。

回答by janih

You probably have security constraints in your web.xml: reference. That is why it failed when you commented out the jetty-test.xml configuration.

您的 web.xml: reference 中可能有安全限制。这就是当您注释掉 jetty-test.xml 配置时它失败的原因。