Files are locked on Windows and can't be replaced
Jetty buffers static content for webapps such as html files, css files, images etc and uses memory mapped files to do this if the NIO connectors are being used. The problem is that on Windows, memory mapping a file causes the file to be locked, so that the file cannot be updated or replaced. This means that effectively you have to stop Jetty in order to update a file.
Jetty provides a configuration switch in the
webdefault.xml file for the
DefaultServlet which enables or disables the use of memory mapped files. If you are running on Windows and are having file locking problems, you should set this switch to disable memory mapped file buffers.
webdefault.xml file is found in the
org/mortbay/jetty/webapp/webdefault.xml. Extract it to a convenient disk location and edit it to change
Then, ensure that your custom webdefault.xml file is applied to all of your webapps by editing all of your relevant jetty configuration files (eg
etc/jetty-plus.xml and any custom files you may have) and indicating the location of the custom file:
Alternatively, if you have individually configured your webapps, you need to call the
WebAppContext.setDefaultsDescriptor(String path) method:
A WebAppContext can be forced to always copy a web app directory on deployment to avoid the file locking issue.
This can be set in a context deployment file as follows: