Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Homepage:http://www.eclipse.org/jetty
Downloads: http://download.eclipse.org/jetty/
Documentation:http://www.eclipse.org/jetty/documentation/current/
About:http://www.eclipse.org/jetty/about.php
Jetty Powered:http://www.eclipse.org/jetty/powered/
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Files are locked on Windows and can't be replaced

Detailed Description

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.

Remedy

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.

The default webdefault.xml file is found in the lib/jetty.jar at org/mortbay/jetty/webapp/webdefault.xml. Extract it to a convenient disk location and edit it to change useFileMappedBuffer to false:

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.xml, 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:

Alternate Remedy

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.

  • No labels
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery