Search code examples
eclipsejettyembedfile-locking

Embedded Jetty server 8 and Eclipse IDE on Windows 7 cannot save file


I am using Eclipse IDE and and embedded Jetty Server on Windows 7.

I can run the app by starting jetty and view it my browser without a problem.

However if I edit a file in my app which is in "webapp" folder e.g. a JavaScript file, I get the following error

Could not write file: sample.js
sample.js (The requested operation cannot be performed on a file with a user-mapped section open)

If I stop Jetty I can save the file. So is there a way to stop Jetty locking the file?

Here's how I create the WebApp context in JettyServer.java

private static WebAppContext createWebapp() {
    String webAppDir = "src/main/webapp/";
    WebAppContext webApp = new WebAppContext();
    webApp.setContextPath(CONTEXT_PATH);
    webApp.setResourceBase(webAppDir);
    webApp.setParentLoaderPriority(true);
    return webApp;
}

Solution

  • This is common problem for jetty within windows environment. You should follow this insturction to save file without shutdown the jetty server.