I set-up a jetty security realm as follows (to be used with mvn jetty:run
).
this works:
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
<?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.xml
file, as follows:
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
You can change this default port number by using the system property jetty. port on the command line, for example, "mvn -Djetty. port=9999 jetty:run". Alternatively, you can specify as many connectors as you like.
Using the Jetty Plugin enables you to quickly test your web application by skipping the last two steps. By default the Jetty Plugin scans target/classes for any changes in your Java sources and src/main/webapp for changes to your web sources.
Deploying by Copying WAR The easiest way to deploy a web application to Jetty server is probably by copying the WAR file into the $JETTY_HOME/webapps directory. Jetty will scan its $JETTY_HOME/webapps directory at startup for web applications to deploy. Our new app will be deployed at /jetty-app context.
Start Jetty standalone from the JAR file. To start Jetty, switch on the command line to the installation directory and issue the following command. To stop Jetty press Ctrl + C . To start Jetty as Windows service you can use Apache Procrun.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With