-
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
DefaultServlet configured for a subdir responds with 404 on existing files #11884
Comments
Since you are using Windows ... Differences in case will trigger all kinds of security and resource alias issues. Do this ... Path base = Path.of("c:/my/folder");
String baseStr = base.toRealPath().toString(); // use the filesystem specific naming and case for this reference.
webappContext.setBaseResourceAsString(baseStr); |
Thanks. I tried this, but it makes no difference. Just want to add that the web.xml contains no further servlets or filters, and also the directory doesn't contain symlinks. What else could cause this issue? |
Alias issues probably. webappContext.clearAliasChecks(); |
Also, turn on server dump and see if the changes you made in the web.xml are being applied. (namely that the servlet "default" exists and is mapped according to what you want/need) server.setDumpAfterStart(true);
server.start(); |
Thanks for your help! Using WebAppContext (see the (adapted) configuration above) - does not work, the dump says:
Using ServletContextHandler (without web.xml) - does work:
The dump says:
When comparing both dumps,
My remaining questions are:
|
@gluser1357 actually, the |
@janbartel thank you for clarification. Following the example at https://github.com/jetty/jetty-examples/blob/12.0.x/embedded/ee10-file-server/src/main/java/examples/ServletFileServerMultipleLocations.java and adapting it led to the working ServletContextHandler-based solution above which requires (Jetty-related) programmatic configuration of servlets, filters and context listeners. Now, in our context, we use Tomcat for production and Jetty for local and CI testing based on a general web.xml configuration that can be used one-to-one for both Tomcat and Jetty. Using a ResourceHandler seems to be, at first glance, just another (Jetty-specific) programmatic approach which - in our case - may not have advantages over the ServletContextHandler-based solution above. Or do I miss something? The ResourceServlet - sounds also interesting. Is it Jetty-specific? Concerning the other related question above, could you give me also some feedback? That would be really great. |
You need
You need
This is what the
If you're not using the |
@janbartel Thank you for referencing jetty-maven-plugin! That sounds great and I will test it. We still look for a container-independent solution serving all url endpoints (url-pattern |
Jetty Environment: ee10 (Jetty 12.0.10)
Java version: OpenJDK 17.0.3
OS: Windows 10
With Jetty 12 we have (in contrast to former Jetty versions like 10 and likely also 11) the following issue with ee10 that static files wont be served when the DefaultServlet is configured only for a subpath:
Configuration:
web.xml:
Code:
Data:
Effects:
It seems that the file locations are not resolved correctly if the DefaultServlet is configured for a subpath only (via doc/* in web.xml). Is this a possible bug in ee10's DefaultServlet?
The text was updated successfully, but these errors were encountered: