Prevent Tomcat redeploying when running Eclipse in debug mode
Posted by davidnewcomb on 05 Jan 2009 in Techie
Been spending a lot of time developing web applications under Eclipse, using Tomcat as the servlet container. The most valuable aspect of using Tomcat and Eclipse together is being able to run your web application in Tomcat debug mode. The coolest thing about it is that you can fix problems while the application container is running. When Eclipse detects that you have saved a file, it recompiles the method or class that has changed and injects it back into the application drops a stack frame and places your run line pointer back to the top of the new code. How cool is that?
Tomcat has a change detection system that notices that one of the classes has changed and tries to redeploy the application. Normally under a live environment this is a good thing because it is a nice easy way of installing new software with the minimum of down time. Under development, however, this is a real pain. Not only does the application run at half speed (because it is in debug mode), often most of the modules can’t cope [yet ;)] with the redeploy signal they get and become confused - which is never a good thing!
To tell Tomcat not to redeploy when it notices a change is quite simple, once you know how. Place this file in
WebContent/META-INF/context.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/context" debug="1" reloadable="false">
<Parameter name="runtimeEnvironment" value="DEVEL" override="false"/>
<!-- other directives -->
</Context>
and change /context to the name of your application’s context.
Now when there is a change in the application Eclipse will signal a redeploy, but Tomcat will ignore it. If you change an area of code that can’t be hot-swapped then Eclipse will tell you (as normal), but at least now you won’t have to restart your container all the time.No feedback yet
Form is loading...