views:

1187

answers:

2

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 having to compile and deploy.

Fortunately, Jetty is great for this. It is a pure-java web server. It comes with a really nice maven plugin which lets you launch Jetty reading directly from your build tree -- no need to package a war file or deploy. It even has a scanInterval setting: put this to a non-zero value and it will watch your java files and various config files for changes and automatically re-deploy a few seconds after you make a change.

There's just one thing keeping me from nirvana. I have javascript and css files in my src/main/webapp directory which just get served up by Jetty. I would like to be able to edit these and have the changes show up when I refresh the page in the browser. Unfortunately, Jetty holds these files open so I can't (on Windows) modify them while it is running.

Does anyone know how to make Jetty let go of these files so I can edit them, then serve up the edited files for subsequent requests?

A: 

It is probably the browser that is holding on to it.

inside I.E : Tools | Internet Options | Temporary Internet Files > Settings, click the Radio button "Every visit to the page". press OK.

Before you do that, Delete all the temporary internet files.

anjanb
I think he's talking about windows/jetty locking the files so they can't be edited.
Draemon
This answer is completely incorrect. I would down-vote, but cannot.
Matt Fisher
+5  A: 

Jetty uses memory-mapped files to buffer static content, which causes the file-locking in Windows. Try setting useFileMappedBuffer for DefaultServlet to false.

Files locked on Windows (from the Jetty wiki) has instructions.

Athena
Thanks! that's exactly what I wanted. I would mark this as the "accepted" answer if stackoverflow would allow it (I'm not sure why it won't).
mcherm
I tried those instructions, and after a bit of fiddling (mostly figuring out how to specify in my POM that I was using a customized webdefault.xml file) I got it working. Thanks again.
mcherm
Cool, glad to hear you got i tworking!
Athena