-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
jetty-maven-plugin fails to run ServletContainerInitializer on Windows due to URI case comparison bug #5870
Comments
Passing maven dependency paths via getCanonicalFile() generates the correct URI e.g.: new File("c:\\maven\\repository\\org\\apche\\logging\\log4j\\log4j-web\\2.14.0\\log4j-web-2.14.0.jar").getCanonicalFile().toPath().toUri() produces: file:///C:/maven/repository/org/apche/logging/log4j/log4j-web/2.14.0/log4j-web-2.14.0.jar (c.f. |
Signed-off-by: Jan Bartel <[email protected]>
Add a test for Resource.equals Signed-off-by: Jan Bartel <[email protected]>
+ Eliminating OS.MAC (as it doesn't support drive letters) + Adding alt URI syntax version as well
* Issue #5870 Windows URI case comparison fails Signed-off-by: Jan Bartel <[email protected]> * Issue #5870 - Updating Windows tests + Eliminating OS.MAC (as it doesn't support drive letters) + Adding alt URI syntax version as well Co-authored-by: Joakim Erdfelt <[email protected]>
Fixed by #5873. |
Jetty 9.4.35.v20201120
Java 1.8.0_191
Windows 10
Maven 3.6.3
The jetty-maven-plugin can fail to run ServletContainerInitializers on Windows due to a URI case comparison bug.
My maven project includes:
This jar includes:
From the debug output below, the log4j-web dependency is passed to Jetty as a File:
Later on, the log shows that the Log4jServletContainerInitializer has been excluded:
This log is coming from
AnnotationConfiguration.isFromExcludedJar(WebAppContext context, ServletContainerInitializer sci, Resource sciResource)
and is occurring because of the following code in which usesURI.equals()
to compare URIs - this doesn't treat drive letters as case insensitive.The relevant variables in to
isFromExcludedJar
are:"file:///c:/maven/repository/org/apache/logging/log4j/log4j-web/2.14.0/log4j-web-2.14.0.jar"
"file:///c:/maven/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar"
"file:///c:/maven/repository/org/apache/logging/log4j/log4j-api/2.14.0/log4j-api-2.14.0.jar"
"file:///c:/maven/repository/org/apache/logging/log4j/log4j-core/2.14.0/log4j-core-2.14.0.jar"
The comparison:
r.getURI().equals(loadingJarURI);
fails as the URIs:
are not equal despite them being logically equivalent.
The drive letter case mismatch between orderedJars and sciResource occurs because Maven passes the dependency file paths with lowercase drive letters whereas
AnnotationConfiguration.getJarFor(ServletContainerInitializer service)
returns URIs with uppercase drive letters.In my project,
org.eclipse.jetty.maven.plugin.JettyWebAppContext.setWebInfLib(List<File> jars)
receives a list of files derived from project.getArtifacts():The corresponding URI returned (as a PathResource) by
AnnotationConfiguration.getJarFor(ServletContainerInitializer service)
for Log4jServletContainerInitializer isfile:///C:/work/ext/maven/repository/org/apache/logging/log4j/log4j-web/2.14.0/log4j-web-2.14.0.jar
The relevant log output is shown below:
pom.xml
web.xml
AppServlet.java
The text was updated successfully, but these errors were encountered: