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.