Support

Forums

Contact Me

When using Maven jetty:run, CSS and JavaScript files are never updated

apache_maven

 jetty-logo-80x22

I was getting mad because jetty was refusing to redeploy my static files (xhtml, css) in Eclipse until I find the reason

The Jetty Web Server provides a HTTP server and Servlet container capable of serving static and dynamic contend either from a standalone or embedded instantiations.

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.

To fix this, add a line with to your maven-jetty-plugin configuration:

org.mortbay.jetty 
maven-jetty-plugin 
6.1.5
   
  ... 
  src/main/resources/webdefault.xml 
  

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:

 
    useFileMappedBuffer 
     false 
   

Copy the changed file into src/main/resources/ of your project.

The problem is explained more in Jetty's documentation.

You might also like:
Easily Compress Web Application Resources with EhCache
218 days ago
Easily Compress Web Application Resources with EhCache
Resources such as JavaScript and CSS files can be compressed before being sent to the browser, imp
Tomcat 7 and Apache Maven
218 days ago
Tomcat 7 and Apache Maven
Here is 3 different way to control the lifetime a local Tomcat 7 container using Apache Maven. A t
Apache Maven copy local file to a remote server server using
406 days ago
Apache Maven copy local file to a remote server server using
I will show you in an Apache Maven configuration file how to copy files to server each time the pa
Apache M2Eclipse: Get rid of Duplicate resources when openin
412 days ago
Apache M2Eclipse: Get rid of Duplicate resources when openin
In this small post, I’ll show you how to remove duplicated resources in the Open Resource view o
Apache Maven 3 Cookbook
554 days ago
Apache Maven 3 Cookbook
  First a big thanks to Packt Publishing for having sent me this book to review! I did enj
Apache Maven 3 Cookbook Review
600 days ago
Apache Maven 3 Cookbook Review
Thanks to Packt Publishing for having sent me this book to review. I will publish a review in the
blog comments powered by Disqus

Donations

Thank You for supporting my work