Hi Ludovic
I’m more than willing to provide the pom.xml I use, and full source for how I set up the server, or anything else that may help.
All of the logic worked 100% perfectly until Jetty 10.0.0, any Jetty 9.x version it works correctly in a detached JAR on my Linux box.
As soon as Jetty 10.0.0 was used, this issue becomes effective – in the NetBeans 14 IDE, it still works with Jetty 10.0.0 (or higher) but running
the JAR in which Jetty is embedded on a detached JRE under Linux, with the resources (html files, graphics, css, js files) referenced as
jar:file:/usr/src/verdi/verdi-12-JDK17-jar-with-dependencies.jar!/static
since Jetty 10.0.0, it always returns 404 for all .html, .jsp, etc. files in /static – which is in the root of the JAR Jetty is embedded in.
Thanks again,

CONFIDENTIALITY NOTICE AND DISCLAIMER: This e-mail transmission contains confidential Information which is the property of the sender and which
is subject to legal privilege and/or copyright and intended only for the above-mentioned addressee. If you are not the intended recipient, you are hereby notified that any unauthorized use, disclosure, copying or distribution of the content of the e-mail transmission
or the taking of any action in reliance thereon or pursuant thereto, is strictly prohibited and may be unlawful and may lead to prosecution. Should you have received this e-mail in error, please immediately notify us. The views, policies and comments contained
in this e-mail are those of the sender thereof and should not be construed as the views, policies and/or comments of the organization. We cannot assure that the integrity of this e-mail communication has been maintained nor that it is free of errors, interference
or interception and will not accept any liability or responsibility in this regard. By opening our emails, you indemnify us of any liability.
From: Stefan Viljoen
Sent: Tuesday, September 6, 2022 3:20 PM
To: JETTY user mailing list <jetty-users@xxxxxxxxxxx>
Subject: RE: [jetty-users] Jetty-11.0.11 embedded - WebAppContenxt class cannot parse file:jar references
Hi Ludovic
Thanks for replying!
I’ve manged to do exactly what you describe, only it ONLY ever works -inside- Netbeans 14 in windows. Running the JAR in Linux with the Oracle
JRE 17 exhibits the error.
I’m new to Java and Jetty, not exactly sure how to setup a reproducer?
Did you run your test case in a detached JRE, -NOT- in an IDE? If I do this in Netbeans 14 in Windows, it works 100% perfectly.
It fails completely if run outside NetBeans, in the official Oracle JRE 17 on Linux, outside any IDE.
To reproduce:
In the JAR from which the embedded Jetty instance runs, there is a "static" folder in the root of the jar.
The "static" folder contains an index.html to render.
The JAR must be run in a detached JRE - not inside an IDE because it functions correctly as long as run inside
the IDE (Netbeans 14 in my case) as the WebAppContext contextPath then becomes
file:///... instead of jar:file:...
Code - WebHost.java:
''
server = new Server(AppSettings.getJettyServerPort());
String webDir = this.getClass().getClassLoader().getResource("static").toExternalForm();
WebAppContext waContext = new WebAppContext(webDir, "/");
waContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", "./[^/]servlet-api-[^/]\.jar$|./javax.servlet.jsp.jstl-.\.jar$|./[^/]taglibs.\.jar$");
server.setHandler(waContext);
server.setStopAtShutdown(true);
server.setStopTimeout(0x2710L);
server.start();
''
With
"webDir" = jar:file:/usr/src/verdi/verdi-12-JDK17-jar-with-dependencies.jar!/static
for 127.0.0.1:8086/index.html
Jetty 10.0.0 and up, if the JAR is run by a detached Oracle 17 JRE instance under Linux, returns
HTTP ERROR 404 Not Found
URI: | /index.jsp -- | -- 404 Not Found org.eclipse.jetty.servlet.ServletHandler$Default404Servlet-5dc3fcb7
Regress to latest Jetty 9, above works correctly, and
jar:file:/usr/src/verdi/verdi-12-JDK17-jar-with-dependencies.jar!/static
can be resolved by the WebAppContext class, with the code being run in a detached non-IDE based JRE in Linux.
Expected behaviour:
With an instance of the WebAppContext class registered as a handler in embedded Jetty server versions from
10.0.0 and up, instances of the WebAppContext class must be able to retrieve and serve resources in the same JAR the embedded Jetty instance is running out of, with WebAppContext.ContextPath specified as
jar:file:/usr/src/verdi/verdi-12-JDK17-jar-with-dependencies.jar!/static
when the code is run in a detached JRE separate from the IDE where the code was created.
Thanks again!
Kind regards,

CONFIDENTIALITY NOTICE AND DISCLAIMER: This e-mail transmission contains confidential Information which is the property of the sender and which
is subject to legal privilege and/or copyright and intended only for the above-mentioned addressee. If you are not the intended recipient, you are hereby notified that any unauthorized use, disclosure, copying or distribution of the content of the e-mail transmission
or the taking of any action in reliance thereon or pursuant thereto, is strictly prohibited and may be unlawful and may lead to prosecution. Should you have received this e-mail in error, please immediately notify us. The views, policies and comments contained
in this e-mail are those of the sender thereof and should not be construed as the views, policies and/or comments of the organization. We cannot assure that the integrity of this e-mail communication has been maintained nor that it is free of errors, interference
or interception and will not accept any liability or responsibility in this regard. By opening our emails, you indemnify us of any liability.
From: jetty-users <jetty-users-bounces@xxxxxxxxxxx>
On Behalf Of Ludovic Orban
Sent: Tuesday, September 6, 2022 2:09 PM
To: JETTY user mailing list <jetty-users@xxxxxxxxxxx>
Subject: Re: [jetty-users] Jetty-11.0.11 embedded - WebAppContenxt class cannot parse file:jar references
I just tried configuring a WebAppContext and make it serve the contents of a jar file with Jetty 11 and it worked just fine.
Could you please create a reproducer we can try out? This way it should be rather quick to figure out what's wrong to help you out.
Hi guys
Ok I’ve refined this down. See my original question below.
The problem there is that if I do this to set up a Jetty WebAppContext:
--
.
.
.
String webDir = this.getClass().getClassLoader().getResource("static").toExternalForm();
WebAppContext waContext = new WebAppContext(webDir, "/");
.
.
.
--
I get for “webDir”
--
jar:
file:
/usr/src/verdi/verdi-
12-
JDK17-jar-
with-dependencies.
jar!/
static
--
which is CORRECT - there IS a folder “static” in the root of the JAR Jetty is embedded in and running out
of, and that “static” folder contains the .html, .js, etc. files I need Jetty to serve as a static website at x.x.x.x:80 to web-browser, using an instance of the Jetty WebAppContext class.
However, it appears Jetty’s WebAppContext class -CANNOT- parse jar:file references to web app -files-.
If I have a “webDir” of
file:/// (e.g. just plain files outside the JAR) it works perfectly, and the Jetty WebAppContext class can serve out the site and does so perfectly to web-browsers visiting the server IP over HTTP.
How can one get Jetty’s WebAppContext class (for Jetty 11.0.11) to parse file:jar references so one can serve
static HTML out of an embedded Jetty 11.0.11 instance from the same physical JAR file Jetty 11.0.11 is embedded in and running out of?
(This was working in Jetty 9, I recently upgraded and the WebAppContext class seems to have lost the capacity to parse file:jar references?)
Thanks!

CONFIDENTIALITY NOTICE AND DISCLAIMER: This e-mail transmission contains confidential
Information which is the property of the sender and which is subject to legal privilege and/or copyright and intended only for the above-mentioned addressee. If you are not the intended recipient, you are hereby notified that any unauthorized use, disclosure,
copying or distribution of the content of the e-mail transmission or the taking of any action in reliance thereon or pursuant thereto, is strictly prohibited and may be unlawful and may lead to prosecution. Should you have received this e-mail in error, please
immediately notify us. The views, policies and comments contained in this e-mail are those of the sender thereof and should not be construed as the views, policies and/or comments of the organization. We cannot assure that the integrity of this e-mail communication
has been maintained nor that it is free of errors, interference or interception and will not accept any liability or responsibility in this regard. By opening our emails, you indemnify us of any liability.
From: Stefan Viljoen
Sent: Monday, September 5, 2022 10:53 AM
To: jetty-users@xxxxxxxxxxx
Subject: Jetty-11.0.11 embedded - 404 for all static html files or .jsp's in JAR under Linux JDK 17
Hi guys
Desperately looking for some help or pointers – been at this issue for two weeks solid now:
I have a Maven-based embedded Jetty-11.0.11 project in an “uber JAR” (jar-with-all-dependencies) in JDK17 that
I inherited from a dev that left the company.
I got it from him at Jetty-9 under JDK1.8, and have successfully upgraded it to Jetty-11.0.11 under JDK17 (at
least, it works, but only -inside- Netbeans14…!) by changing the maven pom.xml to refer to newer versions of apache-jsp, apache-jstl, and jetty itself (for Maven.)
I have no web.xml or WEB-INF folder at all in the project.
The static content (.html, .css and .js files) for the webpages it contains, are hosted in the project .JAR
at src\main\webapp\static
After upgrading to Jetty-11.0.11 and JDK17, I could run the project in Netbeans 14 debug mode in Windows 10
and visit the “Netbeans 14”-ed Jetty instance in a browser which rendered the static .html and .jsp content correctly.
If I copy the Jetty-11.0.11-using JAR to a Linux host and run it under JDK17 there, NONE of the static .html
and .jsp content inside the JAR can be found anymore. When running in JDK17 under Linux in the embedded JAR, Jetty responds:
--
HTTP ERROR 404 Not Found
URI:
|
/
|
STATUS:
|
404
|
MESSAGE:
|
Not Found
|
SERVLET:
|
org.eclipse.jetty.servlet.ServletHandler$Default404Servlet-726a17c4
|
--
for any and all .html and .jsp files inside the JAR.
Where can I start to look to get Jetty-11.0-11 embedded in an uber-JAR to render .html and .jsp files inside
the JAR when run in a Linux-based JDK 17 instance?
No exceptions or any errors is emitted by Jetty.
I run Jetty in Ubuntu 20.04-LTS with official Oracle JDK17 as
/usr/lib/jvm/jdk-17/bin/java -Djavax.net.ssl.trustStore=/usr/lib/jvm/jdk-17/lib/security/cacerts -cp /usr/src/verdi/verdi-12-JDK17-jar-with-dependencies.jar
verishare.App
Anybody got ANY idea why Jetty-11.0.11 only works inside Netbeans 14 debug mode in Windows under Oracle JDK
17, but not in a Linux-based Oracle JDK 17 (where it WAS working in Linux with JDK 1.8 and Jetty-9)?
Where do I even start?
More than willing to provide more info such as the POM and the server setup code if anybody wants to help…
Thanks!
Kind regards,
Stefan

CONFIDENTIALITY NOTICE AND DISCLAIMER: This e-mail transmission contains confidential
Information which is the property of the sender and which is subject to legal privilege and/or copyright and intended only for the above-mentioned addressee. If you are not the intended recipient, you are hereby notified that any unauthorized use, disclosure,
copying or distribution of the content of the e-mail transmission or the taking of any action in reliance thereon or pursuant thereto, is strictly prohibited and may be unlawful and may lead to prosecution. Should you have received this e-mail in error, please
immediately notify us. The views, policies and comments contained in this e-mail are those of the sender thereof and should not be construed as the views, policies and/or comments of the organization. We cannot assure that the integrity of this e-mail communication
has been maintained nor that it is free of errors, interference or interception and will not accept any liability or responsibility in this regard. By opening our emails, you indemnify us of any liability.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users