Whether you are a graphic designer, with little knowledge of computer programming, or a versatile developer building everything all by yourself, you might want at some time to edit static files like stylesheets, hit the refresh button of your browser and check new changes. But you cannot because you realized once the server launched, no static files can be modified.
If you happen to be developing under Windows, you will notice that mvn jetty:run locks files down 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. SBT users might encounter quite the same situation with the embedded Jetty.
Maven on Windows platform
- 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
- move to test/resources
mv org/mortbay/jetty/webapp/webdefault.xml src/test/resources/
- change useFileMappedBuffer flag to false in webdefault.xml
- tell mvn jetty plugin to use that file in your pom.xml:
- feel your productivity elevated
(This solution was provided by Sasa Skevin.)
Add this configuration snippet to any web.xml :
<!-- Override init parameter to avoid nasty -->
<!-- file locking issue on windows. -->
This method has one drawback. If you deploy on Tomcat it will complain about default server. Tomcat uses same name. Albeit its easier.
SBT on Unix
Add the following lines to the SBT definition of your projects, typically located in the /project/build/.scala:
override def managedStyle = ManagedStyle.Maven
override def jettyWebappPath = webappPath
override def scanDirectories = Nil