Jetty 11 embedded cannot parse jar:file references in WebAppContext for static content

Viewed 23

In Jetty setup code I've got, this WebAppContext:

.
.
.
String webDir = this.getClass().getClassLoader().getResource("static").toExternalForm();

WebAppContext waContext = new WebAppContext(webDir, "/");  
.
.
.

which resolves to

jar:file:/usr/src/verdi/verdi-12-JDK17-jar-with-dependencies.jar!/static

This "static" folder exists in my JAR and contains the static website .html, .js, .css etc. I want to serve out with Jetty.

However, trying to a access any of the files in this folder from a web-browser when the Jetty instance in the JAR is running, results in

HTTP ERROR 404 Not Found
URI:    /
STATUS: 404
MESSAGE:    Not Found
SERVLET:    org.eclipse.jetty.servlet.ServletHandler$Default404Servlet-726a17c4

E. g. Jetty apparently cannot parse the reference

jar:file:/usr/src/verdi/verdi-12-JDK17-jar-with-dependencies.jar!/static

in a Jetty WebAppContext instance as referring to static files inside a folder in the root of the JAR that Jetty is embedded in and running out of, that need to be served for browser HTTP requests received by that WebAppContext.

How can I correct this so an instance of Jetty's WebAppContext class can "see" the files in jar:file:/usr/src/verdi/verdi-12-JDK17-jar-with-dependencies.jar!/static in the same JAR it is embedded in and running out of?

Thanks!

EDIT:I have confirmed that if I regress the Jetty version back far enough to older versions, the reference jar:file:/usr/src/verdi/verdi-12-JDK17-jar-with-dependencies.jar!/static -does- start working and functions perfectly, and the older Jetty instance can serve the resources in the /static folder to any web-browsers that request them.

EDIT: This is now a bug ticket under https://github.com/eclipse/jetty.project/issues/8549

0 Answers
Related