I am building Java web applications, and I hate the traditional \"code-compile-deploy-test\" cycle. I want to type in one tiny change, then see the result INSTANTLY, without
Similar to @kybernetikos answer, but without having to recreate the DefaultServlet:
// Startup stuff
final Server server = new Server(port);
WebAppContext webAppContext = new WebAppContext(path, "/")
webAppContext.setInitParam(
"org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
server.setHandler(webAppContext);
server.start();
server.join();
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.
I also had this problem.
And I didn't want to create any additional classes and messing with web.xml
So here is what you can do:
Assuming you project is maven based and (lets say) called 'my-web-app'
create a file my-web-app/jetty/jetty-config.xml
put this stuff inside:
<?xml version="1.0" encoding="UTF-8"?>
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call name="setInitParameter">
<Arg>org.eclipse.jetty.servlet.Default.useFileMappedBuffer</Arg>
<Arg>false</Arg>
</Call>
</Configure>
Here is your jetty config:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<httpConnector>
<host>localhost</host>
<port>8801</port>
</httpConnector>
<webApp>
<contextPath>/${project.artifactId}</contextPath>
</webApp>
<contextXml>${project.basedir}/jetty/jetty-config.xml</contextXml>
</configuration>
</plugin>
This solution will add an attribute to you servlet-context which will disable static resources locking.
Have fun :)
When using IntelliJ and Jetty 9 with a ResourceHandler one of the solutions is to edit the static content in the target directory, instead of the source file.
Setting false to useFileMappedBuffer in webdefault.xml did NOT work for me (Jetty 8.1.10.v20130312). Fortunately setting maxCachedFiles to 0 (also in webdefault.xml) did the trick.