When using the ResourceHttpRequestHandler to serve static resources the ServletContextResource's getFile() method that is used doesn't work when not deploying exploded.
Here is the scenario:
- wire up in spring config
<mvc:resources mapping="/resources/**" location="/resources/" />
- DispatcherServlet gets the request and delegates to the ResourceHttpRequestHandler.getResource()
- ResourceHttpRequestHandler uses the ServletContextResource from it's list of locations to check "exists" and "readable"
- ServletContextResource says yes it exists
- isReadable() hops to AbstractFileResolvingResource, which determines that is is a "file system resolution" and calls getFile() on ServletContextResource. NOTE: the url that is returned by Weblogic is file:c:/weblogic/tmp/blah/blah/blah/resources/images/img.gif
- The ServletContextResource.getFile() uses WebUtils.getRealPath(), which is returning /resources/images/img.gif and it tries to then create a File object.
I was able to work around this issue by creating and plugging in a custom ServletContextResource class that overrides the getFile() method and does this:
public File getFile() throws IOException
I have tested this using Weblogic 10.3 deployed exploded, not exploded, and using the eclipse plugin which is basically exploded.