How to enable hot deployment in tomcat

I can write an ant script that copies updated class files to web-inf\classes in tomcat. But how can I tell Tomcat 7.0 to automatically get modified class files from the web-inf/classes directory?

I tried to set autoDeploy="true" in the tomcat server.xml host configuration, but when a change is detected, the Tomcat session will be destroyed. Can I easily replace the eclipse tomcat plugin in Intellij

+4
java-ee intellij-idea tomcat tomcat7
Sep 08 '15 at 13:24
source share
4 answers

I ended up using the HotSwapAgent tool . This is a free alternative to JRebel.

+7
Sep 10 '15 at 19:32
source share

Tomcat can only "hot" replace a certain type of file, such as JSP , and static files, such as JavaScript, CSS, etc. If you disable caching , but cannot "hot" replace Java classes, restart webapp. To achieve a hot exchange of Java classes, Ive seen JRebel ads all over the world, but have not tried their product.

However, you could save the Tomcat session by commenting on the directive as described on the Tomcat documentation site: http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html#Disable_Session_Persistence .

Finally, you can write an ANT script to build the WAR and redeploy each time the script runs.

Example build.xml:

 ... <target name="tomcat-stop"> <exec executable="${server.home}/bin/catalina.bat"> <arg value="stop"/> </exec> </target> <target name="tomcat-start"> <exec executable="${server.home}/bin/startup.bat"> <arg value="start"/> </exec> </target> ... <target name="all" depends="tomcat-stop,clean,init,compile,junit-slow,make_war,deploy,tomcat-start"></target> 

In any consolidation, I would avoid using the Eclipse Tomcat Plugin for two reasons.

  • Most versions of Eclipse already have Tomcat as a server adapter and come with some options.
  • Prevent IDE bloat with plugins.
+4
Sep 09 '15 at
source share

There is a new plugin for intellij that supports it: https://plugins.jetbrains.com/plugin/9492-smart-tomcat

0
Dec 10 '18 at 17:41
source share

Apparently, another option is to use jetty (for example, during development); it has the ability to make hot swapping on the fly more easily.

-one
Oct. 12 '17 at 17:18
source share



All Articles