a few days ago jetty found that Java can not delete files, the file operation has been occupied by the JVM, but changed the tomcat problem disappeared. today again, try the online solution, after I test, directly modify the configuration file sometimes can not take effect, the specific reasons are unclear, we recommend the use of directly modify the Web. xml Filethe red part of the following
files are locked because jetty maps these files in memory by default when using Windows systems, and Windows locks memory-mapped files. The workaround is to modify the configuration of the jetty so that it sets the Usefilemappedbuffer flag bit to False when starting the server.
There are two ways to set up a method, one is to modify the Usefilemappdbuffer flag bit in the Webdefault.xml file. The Webdefault.xml file is a configuration file for the Jetty startup service, and the Web-inf/web.xml file its first in the project is loaded. This file is available by default in the jetty package, which can be extracted, saved in the project root directory, and modified by the Usefilemappedbuffer node.
12 |
<param-name>useFileMappedBuffer</param-name><param-value>false</param-value>
|
A reference to this file is then added to the Build.gradle.
123 |
[jettyRun, jettyRunWar,jettyStop]*.with { webDefaultXml = file("${rootDir}/webdefault.xml")}
|
The second method is to modify the files in the project to WEB-INF/web.xml
include this node.
12345 6789 |
< Servlet><!--Override init parameter to avoid nasty--> <!--file locking issue on Windows.--> <servlet-name >default</servlet-name> <init-param> <param-name>usefilemappedbuffer</param-name><param-value>false</param-value> </init-param></SERVLET> |
Jetty Java files cannot delete java files consuming delete invalid runtime locking of static resources workaround