Fixing ‘could not write file’ issue with Jetty on Windows
Xebia has published a very nice article (Maven, jetty plugin et section mappée – French) explaining how to fix the long-standing locking file issue affecting Jetty / Maven users on Windows.
On this platform, Jetty locks all .js or .css files, making it impossible to change their content while the server is still running. This is a big loss of time because you always have to stop/restart jetty to update one of these files.
Note: this issue does not occur on Linux or Mac OSX so I personnaly don’t really care, but for the ones still running on Windows, the post provides 2 possible fixes :
- 1 – Changing the connector : this one did not work for us, Jetty was no longer starting (Class not found).
- 2 – Overriding the defaut web context (webdefault.xml) : it does the trick, Great !
As a result, this is the steps that worked for us :
- Get webDefault.xml from the jetty jar and add it to your project. Package is
org.mortbay.jetty.webapp - Change useFileMappedBuffer to false :
<servlet>
...
<init-param>
<param-name>useFileMappedBuffer</param-name>
<param-value>false</param-value>
</init-param>
...
</servlet> - Add this new webDefault.xml to Jetty config :
...
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.14</version>
<configuration>
<webDefaultXml>
src/main/etc/webdefault.xml
</webDefaultXml>
</configuration>
</plugin>
...
- Restart jetty…. files can be edited.

See original post for additionnal details.







14 de June, 2009 at 8:22 pm
Very straightforward solution.
Also, the file itself has a comment of the parameter about solving the locking problem.
Thanks