public
Description: The Lift web framework for Scala
Home | Edit | New

How To: Fix file locking problem with jetty:run in Windows

Overview

If you happen to be developing under windows you will notice that mvn jetty:run locks files and prevents editing while the server is running. Super annoying. The problem is that jetty memory maps files by default and windows locks memory mapped files.

The problem is discussed in slightly more detail here: When using jetty:run, CSS and JavaScript files are locked – how can I fix this?

Solution

  1. extract webdefault.xml from jetty.jar
     jar -xvf ~/.m2/repository/org/mortbay/jetty/jetty/6.1.16/jetty-6.1.16.jar  org/mortbay/jetty/webapp/webdefault.xml
  2. move to test/resources
    mv org/mortbay/jetty/webapp/webdefault.xml src/test/resources/
  3. change useFileMappedBuffer flag to false in webdefault.xml
        <param-name>useFileMappedBuffer</param-name>
        <param-value>false</param-value>
    
  4. tell mvn jetty plugin to use that file in your pom.xml:
    <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <configuration>
              <webDefaultXml>src/test/resources/webdefault.xml</webDefaultXml>
              ...
    
  5. feel your productivity elevated
Last edited by Xavi-, Mon Sep 07 15:51:29 -0700 2009
Home | Edit | New
Versions: