开发者

Tell Jetty to reload on webapp change, not context.xml change

I have jetty running with some context.xml:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/开发者_如何学JAVAconfigure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
      <Set name="war">path/to/webapp</Set>
      <Set name="contextPath">/</Set>
</Configure>

(The path is not default.) The webapp is rebuilt upon every change, but still I need to fake some write access to the context.xml to make jetty reload the webapp.

Is there a way to tell jetty to reload the webapp upon change?


Jasper,

I found a way to make this work (thanks to this question). If you run Jetty in debug mode and connect the Eclipse debugger to it, the VM will hot-swap the class changes instantly.

Run Jetty with (I'm using Jetty 8 w/ JDK 6):

java -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n -jar start.jar

and then create a standard Remote Debug configuration in Eclipse that looks like this:

Tell Jetty to reload on webapp change, not context.xml change

and hit "Debug". Even if you don't plan on debugging anything, having the debugger connected to the remote Jetty VM will cause the class changes to deployed in real time.

The only thing you should be aware of is the limitations of the VM's ability to hot-swap a class. The "shape" of the class cannot change, so any new class members defined or new methods and you'll need to reload the web context (just "touch" the context's XML file and Jetty will reload it).

Hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜