Java – MVN jetty: running failed to find my loginservice

I set up a dock security domain as follows (for 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>

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

Then I try to delete the jetty test XML file, as shown below

<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 failed:

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 ideas?

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

Solution

Please verify that the sub element < name > mysecurityrealm < / name > for < loginservices > your jetty Maven plugin configuration is the same as < realm name > mysecurityrealm < / realm name > For < login config > on your web XML

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>