| Summary: | relativeResourceBase for the Default Servlet cannot be used in Jetty 7.6 | ||
|---|---|---|---|
| Product: | [RT] Jetty | Reporter: | Grumpy LittleTed <grumpylittleted> |
| Component: | build | Assignee: | Jesse McConnell <jesse.mcconnell> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | CC: | gregw, jetty-inbox |
| Version: | unspecified | ||
| Target Milestone: | 7.5.x | ||
| Hardware: | All | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
Grumpy Ted, The relativeResourceBase feature was intended to be used when using the default server as an extra servlet in a webapp (eg to serve a subdirectory) and not when modifying the default servlet defined in webdefault.xml However, the shared resource cache mechanism need not be turned on by default either. I'll turn that feature off in the default webdefault.xml webdefault change committed Thanks for a prompt response/fix. If caching is being turned off when relativeResourceBase is used this will affect performance. So if we want to continue to use caching and the Default Servlet and constrain serving static files to a specific subdirectory how should we do this? For example if the URL is /a/b/c.html and the real path is /x/y/z/a/b/c.html we could previously have used relativeResourceBase to rebase. So is there a simpler/better way to do this. Primarily I am concerned about not accidentally serving files from other subdirectories through some future change to the configuration which opens up more directories than intended. |
Build Identifier: 7.6 The init code for the DefaultServlet contains these lines if (resourceCache!=null) { if (max_cache_size!=-1 || max_cached_file_size!= -2 || max_cached_files!=-2) LOG.debug("ignoring resource cache configuration, using resourceCache attribute"); // if (_relativeResourceBase!=null || _resourceBase!=null) //CHANGED - REMOVE FOR FIX // throw new UnavailableException("resourceCache specified with resource bases"); //CHANGED - REMOVE FOR FIX _cache=(ResourceCache)_servletContext.getAttribute(resourceCache); LOG.debug("Cache {}={}",resourceCache,_cache); } But the default webdefault.xml means that resourceCache will not be null so if relativeResourceBase has been specified as an init parameter the exception will always be thrown. If the lines I have marked as //CHANGED are removed the code works like the Default Servlet in Jetty 6 - caching works fine according to my tests. I should add that I'm not sure why the " if (_relativeResourceBase!=null || _resourceBase!=null) " guard was added. I'm marking this as a Major severity since it prevents any site using this feature cannot be migrated from Jetty 6. Reproducible: Always Steps to Reproduce: 1. Add a relativeResourceBase to a web.xml 2. Watch the exception always being thrown!