If ApplicationContext.GET_RESOURCE_REQUIRE_SLASH == true then all is good: ApplicationContext.getResourceAsStream(String) checks whether the path has a leading slash and, if not, returns null. If ApplicationContext.GET_RESOURCE_REQUIRE_SLASH == false then ApplicationContext.getResourceAsStream(String) ends up delegating to StandardRoot.getResource(String) and thence to StandardRoot.validate(String), which (regardless of the GET_RESOURCE_REQUIRE_SLASH value) throws IllegalArgumentException if the path doesn't have a leading slash.
With the caveat that I may not have thought this through... If StandardRoot.validate(String) isn't going to change (i.e. it will continue to throw IllegalArgumentException for paths that don't have a leading slash), then perhaps one way to make GET_RESOURCE_REQUIRE_SLASH == false behave as documented would be to doctor the offending path (i.e. prepend "/") before passing it on. Perhaps something roughly like: Old: if (!path.startsWith("/") && GET_RESOURCE_REQUIRE_SLASH) return null; New: if (!path.startsWith("/")) { if (GET_RESOURCE_REQUIRE_SLASH) return null; else path = "/" + path; } The ApplicationContext.getResource(String) method might also need similar-ish treatment.
Thanks for the report. This has been fixed in trunk and 8.0.x (for 8.0.25 onwards). I did use a variation of the patch you proposed. The actua patch was a little more generic and handled getResource() and getResourceAsStream()
*** Bug 58455 has been marked as a duplicate of this bug. ***
Created attachment 33233 [details] Add opportunity for getRealPath(String) to change behavior in according to value of ApplicationContext.GET_RESOURCE_REQUIRE_SLASH You won't be able to get the expected result (not null) If we call method ServletContext.getRealPath("WEB-INF"). (The class org.apache.catalina.core.ApplicationContext was used in my case ) The bad thing is that I cannot change this behavior without tomcat patching. The issue was fixed for ApplicationContext.getResource(String), but it's still actual for ApplicationContext.getRealPath(String).
Fixed for get realPath in trunk and 8.0.x (for 8.0.29 onwards).