jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
https://eclipse.dev/jetty
Other
3.87k stars 1.91k forks source link

NPE when starting jetty-ee10-maven-plugin #9463

Closed Artur- closed 1 year ago

Artur- commented 1 year ago

Jetty version(s) 12.0.0-SNAPSHOT

Java version/vendor openjdk version "19.0.1" 2022-10-18

OS type/version mac os

Description Some of our tests fail to start jetty when using jetty-ee10-maven-plugin while jetty-ee9-maven-plugin works fine. The failure is

[DEBUG] loaded 2 HttpFieldPreEncoders
[DEBUG] oeje10mp.MavenWebAppContext@22d33f1c{ROOT,/,b=null,a=STOPPED} added {SymlinkAllowedResourceAliasChecker@17374d87{base=null,protected=[]},MANAGED}
[DEBUG] oeje10mp.MavenWebAppContext@22d33f1c{ROOT,/,b=null,a=STOPPED} added {org.eclipse.jetty.util.DecoratedObjectFactory[decorators=0],POJO}
[DEBUG] oeje10mp.MavenWebAppContext@22d33f1c{ROOT,/,b=null,a=STOPPED} added {oeje10s.SessionHandler@62888459{STOPPED},AUTO}
[DEBUG] oeje10ss.ConstraintSecurityHandler@506bbd6f{STOPPED} added {org.eclipse.jetty.util.component.DumpableCollection@4f8b5433,POJO}
[DEBUG] oeje10s.SessionHandler@62888459{STOPPED} added {oeje10ss.ConstraintSecurityHandler@506bbd6f{STOPPED},AUTO}
[DEBUG] oeje10ss.ConstraintSecurityHandler@506bbd6f{STOPPED} added {oeje10s.ServletHandler@51780404{STOPPED},AUTO}
[DEBUG] oeje10mp.MavenWebAppContext@22d33f1c{ROOT,/,b=null,a=STOPPED,h=oeje10s.SessionHandler@62888459{STOPPED}} added {org.eclipse.jetty.ee10.servlet.ErrorPageErrorHandler@7aafef4a,POJO}
[DEBUG]   (s) resourceBases = [/projectdirflow/flow-tests/test-pwa/public, /projectdirflow/flow-tests/test-pwa/src/main/webapp]
[DEBUG] STARTING oejur.ResourceFactoryInternals$LifeCycle@1ecf8977{STOPPED}
[DEBUG] STARTED @7445ms oejur.ResourceFactoryInternals$LifeCycle@1ecf8977{STARTED}
[DEBUG] oeje10mp.MavenWebAppContext@22d33f1c{ROOT,/,b=null,a=STOPPED,h=oeje10s.SessionHandler@62888459{STOPPED}} added {oejur.ResourceFactoryInternals$LifeCycle@1ecf8977{STARTED},MANAGED}
[DEBUG] oeje10mp.MavenWebAppContext@22d33f1c{ROOT,/,b=null,a=STOPPED,h=oeje10s.SessionHandler@62888459{STOPPED}} added {org.eclipse.jetty.util.resource.ResourceFactory$2@29efc291,POJO}
[DEBUG]   (s) containerIncludeJarPattern = ^$
[DEBUG]   (f) webApp = oeje10mp.MavenWebAppContext@22d33f1c{ROOT,/,b=[file:///projectdirflow/flow-tests/test-pwa/public/, file:///projectdirflow/flow-tests/test-pwa/src/main/webapp/],a=STOPPED,h=oeje10s.SessionHandler@62888459{STOPPED}}
[DEBUG]   (f) webAppSourceDirectory = /projectdirflow/flow-tests/test-pwa/src/main/webapp
[DEBUG]   (f) webXml = /projectdirflow/flow-tests/test-pwa/${project.baseDir}/src/main/webapp/WEB-INF/web.xml
[DEBUG] -- end configuration --
[INFO] Configuring Jetty for project: Flow tests for PWA annotation
[DEBUG] Set system property vaadin.allow.appshell.annotations=false
[DEBUG] Set system property vaadin.reuseDevServer=false
[DEBUG] Set system property vaadin.devServerPort=0
[DEBUG] Set system property vaadin.frontend.hotdeploy=true
[DEBUG] Set system property vaadin.devmode.liveReload.enabled=false
[DEBUG] Set system property vaadin.devmode.vite.options=--host
[DEBUG] Set system property vaadin.eagerServerLoad=false
[INFO] Classes = /projectdirflow/flow-tests/test-pwa/target/classes
[INFO] Context path = /
[INFO] Tmp directory = /projectdirflow/flow-tests/test-pwa/target/tmp
...
[ERROR] Failed to execute goal org.eclipse.jetty.ee10:jetty-ee10-maven-plugin:12.0.0-SNAPSHOT:run (default-cli) on project flow-test-pwa: Webapp config failure: Cannot invoke "java.net.URI.toURL()" because the return value of "org.eclipse.jetty.util.resource.Resource.getURI()" is null -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.jetty.ee10:jetty-ee10-maven-plugin:12.0.0-SNAPSHOT:run (default-cli) on project flow-test-pwa: Webapp config failure
...
Caused by: java.lang.NullPointerException: Cannot invoke "java.net.URI.toURL()" because the return value of "org.eclipse.jetty.util.resource.Resource.getURI()" is null
    at org.eclipse.jetty.ee10.maven.plugin.AbstractUnassembledWebAppMojo.configureUnassembledWebApp (AbstractUnassembledWebAppMojo.java:154)
    at org.eclipse.jetty.ee10.maven.plugin.AbstractUnassembledWebAppMojo.configureWebApp (AbstractUnassembledWebAppMojo.java:113)
    at org.eclipse.jetty.ee10.maven.plugin.AbstractWebAppMojo.startJetty (AbstractWebAppMojo.java:431)
    at org.eclipse.jetty.ee10.maven.plugin.AbstractWebAppMojo.execute (AbstractWebAppMojo.java:420)
    at org.eclipse.jetty.ee10.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:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)

On code level this is because

webApp.getBaseResource(): [file:///projectdir/flow/flow-tests/test-pwa/public/, file:///projectdir/flow/flow-tests/test-pwa/src/main/webapp/]

originalBaseResource is of type org.eclipse.jetty.util.resource.CombinedResource and originalBaseResource.getURI() is null

How to reproduce? Run mvn jetty:run in https://github.com/vaadin/flow/tree/b7bffcc7d400cbaf98b11d362346ab4efdd17ea0/flow-tests/test-pwa

janbartel commented 1 year ago

Closed via PR #9475