Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #11761 fix jetty maven doco and integration test #11771

Merged
merged 4 commits into from
May 12, 2024

Conversation

janbartel
Copy link
Contributor

Closes #11761

Also fixed name of integration test file.

@janbartel janbartel requested a review from olamy May 9, 2024 00:27
@janbartel janbartel self-assigned this May 9, 2024
Copy link
Contributor

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The demos need to be migrated to the new syntax as well:

jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-jetty-webapp/pom.xml
jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-spec/jetty-ee10-demo-spec-webapp/pom.xml
jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-jetty-webapp/pom.xml
jetty-ee8/jetty-ee8-demos/jetty-ee8-demo-spec/jetty-ee8-demo-spec-webapp/pom.xml
jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/pom.xml
jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-spec/jetty-ee9-demo-spec-webapp/pom.xml

Copy link
Contributor

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the demos launch successfully, the code change looks correct to me. I couldn't actually figure out how to launch the demos, even after reading the documentation.

olamy
olamy previously approved these changes May 9, 2024
Copy link
Member

@olamy olamy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -111,7 +111,9 @@
<loginServices>
<loginService implementation="org.eclipse.jetty.security.HashLoginService">
<name>Test Realm</name>
<config>src/test/resources/test-realm.properties</config>
<config implementation="org.eclipse.jetty.maven.MavenResource">
<resourceAsString>src/test/resources/test-realm.properties</resourceAsString>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indented too much and fails spotless.

Copy link
Contributor

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I installed this patch with mvn clean install -DskipTests. After that, I ran mvn -pl org.eclipse.jetty.ee9.demos:jetty-ee9-demo-jetty-webapp org.eclipse.jetty.ee9:jetty-ee9-maven-plugin:run to attempt to run the demo. The demo failed to run with a trivial Maven error. Fixing that obvious typo with

diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/pom.xml b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/pom.xml
index 8ba0fc74c4f..238a194ddbe 100644
--- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/pom.xml
+++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/pom.xml
@@ -124,8 +124,8 @@
               <version>${project.version}</version>
             </dependency>
             <dependency>
-              <groupId>org.eclipse.jetty</groupId>
-              <artifactId>jetty-servlets</artifactId>
+              <groupId>org.eclipse.jetty.ee9</groupId>
+              <artifactId>jetty-ee9-servlets</artifactId>
               <version>${project.version}</version>
             </dependency>
           </dependencies>

the demo failed to run with

[WARNING] Unable to get name for scope oeje9mp.MavenWebAppContext@3531509c{EE9 Demo Jetty WebApp,/test,file:///home/basil/src/eclipse/jetty.project/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/webapp/,false}{file:///home/basil/src/eclipse/jetty.project/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-jetty-webapp/src/main/webapp/}
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext (NamingManager.java:704)
    at javax.naming.InitialContext.getDefaultInitCtx (InitialContext.java:305)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx (InitialContext.java:342)
    at javax.naming.InitialContext.getNameParser (InitialContext.java:497)
    at org.eclipse.jetty.plus.jndi.NamingEntryUtil.getNameForScope (NamingEntryUtil.java:184)
    at org.eclipse.jetty.plus.jndi.NamingEntryUtil.destroyContextForScope (NamingEntryUtil.java:215)
    at org.eclipse.jetty.ee9.plus.webapp.EnvConfiguration.destroy (EnvConfiguration.java:193)
    at org.eclipse.jetty.ee9.webapp.WebAppContext.destroy (WebAppContext.java:581)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.destroy (ContainerLifeCycle.java:228)
    at org.eclipse.jetty.server.Handler$Abstract.destroy (Handler.java:507)
    at org.eclipse.jetty.server.handler.ContextHandler.lambda$destroy$2 (ContextHandler.java:806)
    at org.eclipse.jetty.server.handler.ContextHandler$ScopedContext.run (ContextHandler.java:1298)
    at org.eclipse.jetty.server.handler.ContextHandler$ScopedContext.run (ContextHandler.java:1285)
    at org.eclipse.jetty.server.handler.ContextHandler.destroy (ContextHandler.java:806)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.destroy (ContainerLifeCycle.java:228)
    at org.eclipse.jetty.server.Handler$Abstract.destroy (Handler.java:507)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.destroy (ContainerLifeCycle.java:228)
    at org.eclipse.jetty.server.Handler$Abstract.destroy (Handler.java:507)
    at org.eclipse.jetty.util.thread.ShutdownThread.run (ShutdownThread.java:142)

I am asking that all demos be tested and fixed if needed.

@janbartel
Copy link
Contributor Author

@basil I think we have some difficulty in executing the maven plugin on the demos - IIRC something to do with the build dependency ordering or something (@olamy can you remember why the plugin might not work on the demos?). I'm tempted to remove the plugin declarations from the demos, except I'm doing a major reorg of the demos in the jetty-12.1.0 branch, which might again make it possible to run the plugin on the demos. All of which is to say, that yes, I agree with you, but the work might be done in 12.1.x rather than 12.0.x.

@olamy
Copy link
Member

olamy commented May 9, 2024

@basil I think we have some difficulty in executing the maven plugin on the demos - IIRC something to do with the build dependency ordering or something (@olamy can you remember why the plugin might not work on the demos?). I'm tempted to remove the plugin declarations from the demos, except I'm doing a major reorg of the demos in the jetty-12.1.0 branch, which might again make it possible to run the plugin on the demos. All of which is to say, that yes, I agree with you, but the work might be done in 12.1.x rather than 12.0.x.

nope nothing to do with build order :). @basil is simply running only this module (not a complete build)

It's just a long time since we have maintained the plugin declarations in all those demos, and we are testing them via the distribution tests now.
I would rather say we delete those declarations (of course, we can fix them, but we have duplicated the wrong configuration in a lot of poms ;) )

@basil
Copy link
Contributor

basil commented May 9, 2024

If the demos can be fixed in a future 12.1.x release, I think that would be useful for people who are trying to figure out how to use this plugin.

I tested these instructions, and they resolved my immediate issue, but I still cannot get the plugin to work in Jetty 12.0.9. After following the instructions in this PR, I now get:

[WARNING] Failed startup of context oeje8mp.MavenWebAppContext@2da7531e{Jenkins v${project.version},/jenkins,file:///home/basil/src/jenkinsci/jenkins/war/src/main/webapp/,false}{file:///home/basil/src/jenkinsci/jenkins/war/src/main/webapp/}
java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.ee8.security.authentication.FormAuthenticator@15763605 in oeje8s.ConstraintSecurityHandler@5742402f{STARTING}
    at org.eclipse.jetty.ee8.security.authentication.LoginAuthenticator.setConfiguration (LoginAuthenticator.java:90)
    at org.eclipse.jetty.ee8.security.authentication.FormAuthenticator.setConfiguration (FormAuthenticator.java:122)
    at org.eclipse.jetty.ee8.security.SecurityHandler.doStart (SecurityHandler.java:339)
    at org.eclipse.jetty.ee8.security.ConstraintSecurityHandler.doStart (ConstraintSecurityHandler.java:346)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:113)
    at org.eclipse.jetty.ee8.nested.AbstractHandler.doStart (AbstractHandler.java:75)
    at org.eclipse.jetty.ee8.nested.ScopedHandler.doStart (ScopedHandler.java:105)
    at org.eclipse.jetty.ee8.nested.SessionHandler.doStart (SessionHandler.java:146)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:113)
    at org.eclipse.jetty.ee8.nested.AbstractHandler.doStart (AbstractHandler.java:75)
    at org.eclipse.jetty.ee8.nested.ScopedHandler.doStart (ScopedHandler.java:105)
    at org.eclipse.jetty.ee8.nested.ContextHandler.startContext (ContextHandler.java:713)
    at org.eclipse.jetty.ee8.servlet.ServletContextHandler.startContext (ServletContextHandler.java:308)
    at org.eclipse.jetty.ee8.webapp.WebAppContext.startWebapp (WebAppContext.java:1176)
    at org.eclipse.jetty.ee8.webapp.WebAppContext.startContext (WebAppContext.java:1146)
    at org.eclipse.jetty.ee8.nested.ContextHandler.doStartInContext (ContextHandler.java:622)
    at org.eclipse.jetty.server.handler.ContextHandler$ScopedContext.call (ContextHandler.java:1231)
    at org.eclipse.jetty.ee8.nested.ContextHandler.doStart (ContextHandler.java:611)
    at org.eclipse.jetty.ee8.servlet.ServletContextHandler.doStart (ServletContextHandler.java:243)
    at org.eclipse.jetty.ee8.webapp.WebAppContext.doStart (WebAppContext.java:502)
    at org.eclipse.jetty.ee8.maven.plugin.MavenWebAppContext.doStart (MavenWebAppContext.java:273)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:113)
    at org.eclipse.jetty.server.Handler$Abstract.doStart (Handler.java:491)
    at org.eclipse.jetty.server.handler.ContextHandler.lambda$doStart$0 (ContextHandler.java:725)
    at org.eclipse.jetty.server.handler.ContextHandler$ScopedContext.call (ContextHandler.java:1237)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:725)
    at org.eclipse.jetty.ee8.nested.ContextHandler$CoreContextHandler.doStart (ContextHandler.java:2151)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:120)
    at org.eclipse.jetty.server.Handler$Abstract.doStart (Handler.java:491)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
    at org.eclipse.jetty.server.Server.start (Server.java:622)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:120)
    at org.eclipse.jetty.server.Handler$Abstract.doStart (Handler.java:491)
    at org.eclipse.jetty.server.Server.doStart (Server.java:563)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.maven.AbstractJettyEmbedder.doStart (AbstractJettyEmbedder.java:206)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.ee8.maven.plugin.JettyRunMojo.startJettyEmbedded (JettyRunMojo.java:95)
    at org.eclipse.jetty.ee8.maven.plugin.AbstractWebAppMojo.startJetty (AbstractWebAppMojo.java:417)
    at org.eclipse.jetty.ee8.maven.plugin.AbstractWebAppMojo.execute (AbstractWebAppMojo.java:403)
    at org.eclipse.jetty.ee8.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:85)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)

To reproduce, you can check out the prototype branch of https://github.com/jenkinsci/jenkins and run mvn -am -pl war,bom -Pquick-build clean install && mvn -pl war jetty:run.

@janbartel
Copy link
Contributor Author

@basil your login service definition for the jetty maven plugin needs to have a realm name, and that name needs to match a login-config from your web.xml. So the plugin needs to look like:

               <loginService implementation="org.eclipse.jetty.security.HashLoginService">
                  <name>Test Realm</name>
                  <config implementation="org.eclipse.jetty.maven.MavenResource">
                    <resourceAsString>${basedir}/src/config/realm.properties</resourceAsString>
                  </config>
                </loginService>

and your web.xml needs to look like:

  <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>Test Realm</realm-name>
    <form-login-config>
       <form-login-page>/logon.html?param=test</form-login-page>
       <form-error-page>/logonError.html?param=test</form-error-page>
    </form-login-config>
  </login-config>

I'll recheck the doco.

Copy link
Contributor

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! Adding back the <name> fixed it for me. I was able to leave it as default and I didn't have to edit web.xml to add a realm name there. The final set of changes that worked for me:

diff --git a/war/pom.xml b/war/pom.xml
index 3db5f853d2..47b59746f1 100644
--- a/war/pom.xml
+++ b/war/pom.xml
@@ -632,9 +638,9 @@ THE SOFTWARE.
         </configuration>
       </plugin>
       <plugin>
-        <groupId>org.eclipse.jetty</groupId>
-        <artifactId>jetty-maven-plugin</artifactId>
-        <version>10.0.20</version>
+        <groupId>org.eclipse.jetty.ee8</groupId>
+        <artifactId>jetty-ee8-maven-plugin</artifactId>
+        <version>12.0.9</version>
         <configuration>
           <!--
             Reload webapp when you hit ENTER. (See JETTY-282 for more)
@@ -647,7 +653,9 @@ THE SOFTWARE.
           <loginServices>
             <loginService implementation="org.eclipse.jetty.security.HashLoginService">
               <name>default</name>
-              <config>${basedir}/src/realm.properties</config>
+              <config implementation="org.eclipse.jetty.maven.MavenResource">
+                <resourceAsString>${basedir}/src/realm.properties</resourceAsString>
+              </config>
             </loginService>
           </loginServices>
           <systemProperties>

Copy link
Contributor

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! It was precisely those tests that I was copying the first time when I (incorrectly) removed <name>, so adding <name> there should help others in the future.

@janbartel janbartel merged commit 6f2f599 into jetty-12.0.x May 12, 2024
6 of 9 checks passed
@janbartel janbartel deleted the jetty-12.0.x-11761-update-maven-doco branch May 12, 2024 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Update documentation for #10077
3 participants