This is common problem for jetty within windows environment. You should follow this insturction to save file without shutdown the jetty server.
Embedded Jetty server 8 and Eclipse IDE on Windows 7 cannot save file
-
03-12-2021 - |
Вопрос
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;
}
Решение
Другие советы
You can turn off this behaviour by setting useFileMappedBuffer to false for the default servlet. Doing so is a bit tricky.
private static WebAppContext createWebapp() {
String webAppDir = "src/main/webapp/";
WebAppContext webApp = new WebAppContext();
webApp.setContextPath(CONTEXT_PATH);
webApp.setResourceBase(webAppDir);
webApp.setParentLoaderPriority(true);
webApp.setInitParam(
"org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
return webApp;
}
DefaultServlet will look for it's own copy of useFileMappedBuffer, which seems to be set deep inside of Jetty. But by prefixing the property name with as above, this value is preferred.