How To Get Rid Of Redeploy Web Application Everytime With Hotswap Agent And Tomcat Plugin

03-09-2015

What is Hotswap Agent?

The main purpose of this project is to avoid infamous change -> restart and wait -> check development lifecycle. Save&Reload during development should be standard and many other languages (including C#) contain this feature

Read more: https://github.com/HotswapProjects/HotswapAgent

Installation

  1. download latest release of DCEVM Java patch and launch the installer (e.g. java -jar installer-light.jar). Currently you need to select correct installer for Java major version (7/8).
  2. select java installation directory on your disc and press "Install DCEVM as altjvm" button. Java 1.7+ versions are supported.
  3. download latest release of Hotswap agent jar, unpack hotswap-agent.jar and put it anywhere on your disc. For example: C:\java\hotswap-agent.jar

Note: You should open command prompt as administrator when running java -jar installer-light.jar command.

Run your application

1. Add following command line java attributes (VM Options):

-XXaltjvm=dcevm -javaagent:PATH_TO_AGENT\hotswap-agent.jar

For example:

-XXaltjvm=dcevm -javaagent:C:\hotswapagent\hotswap-agent.jar

See Intellij IDEA and Netbeans configuration.

2. (optional) create a file named "hotswap-agent.properties" inside your resources directory, see available properties and default values: https://github.com/HotswapProjects/HotswapAgent/blob/master/hotswap-agent-core/src/main/resources/hotswap-agent.properties

3. This agent only works in debug mode. Therefore we should start the application with debug mode. Check that the agent and plugins are initialized correctly.

HOTSWAP AGENT: 9:49:29.548 INFO (org.hotswap.agent.HotswapAgent) - Loading Hotswap agent - unlimited runtime class redefinition.
HOTSWAP AGENT: 9:49:29.725 INFO (org.hotswap.agent.config.PluginRegistry) - Discovered plugins: [org.hotswap.agent.plugin.hotswapper.HotswapperPlugin, org.hotswap.agent.plugin.jvm.AnonymousClassPatchPlugin, org.hotswap.agent.plugin.hibernate.HibernatePlugin, org.hotswap.agent.plugin.spring.SpringPlugin, org.hotswap.agent.plugin.jetty.JettyPlugin, org.hotswap.agent.plugin.tomcat.TomcatPlugin, org.hotswap.agent.plugin.zk.ZkPlugin, org.hotswap.agent.plugin.logback.LogbackPlugin]
...
HOTSWAP AGENT: 9:49:38.700 INFO (org.hotswap.agent.plugin.spring.SpringPlugin) - Spring plugin initialized - Spring core version '3.2.3.RELEASE'

4. Save a changed resource and/or use the HotSwap feaute of your IDEA.

In Intellij Idea, Hotswap feature is activated as follows:

To manage the behavior of the HotSwap mechanism:

Not: Read Intellij Idea more configuration: https://groups.google.com/forum/#!topic/hotswapagent/BxAK_Clniss

Hotswap Agent With Tomcat Plugin

Currently Tomcat 7.0.64 and below versions are supported.

Intellij IDEA Tomcat configuration is:

© 2019 All rights reserved. Codesenior.COM