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:
It seems one can also configure the default jetty Servlet directly in the web.xml. For example:
...Altough, it may completely redefine the default servlet configuration (not sure about that, if anyone can confirm). You could anyway simply extract the webdefault file as explained above, and copy-paste th complete default servlet definition in your web.xml, changing that useFileMappedBuffer parameter to false.