Select Page

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

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

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.

About The Author

I worked with various Insurances companies across Switzerland on online applications handling billion premium volumes. I love to continuously spark my creativity in many different and challenging open-source projects fueled by my great passion for innovation and blockchain technology.In my technical role as a senior software engineer and Blockchain consultant, I help to define and implement innovative solutions in the scope of both blockchain and traditional products, solutions, and services. I can support the full spectrum of software development activities, starting from analyzing ideas and business cases and up to the production deployment of the solutions.I'm the Founder and CEO of Disruptr GmbH.

Categories