Besides the posts about hot deploy on Tomcat Eclipse (WTP), and on JBoss exploded EAR/WAR, this is a similar post about Java hotswap based on the Java Platform Debugger Architecture (JPDA), or more specific layer, the Java Debug Wire Protocol (JDWP).
Yes, “hotswap” does not necessary mean to deploy, the Java app can see different results in runtime just via debugging. Okay later on you can still deploy to the web server so that it can run as production, but the point of hotswap is to speedup development process.
In this field, the leading software is JRebel, but its price is a bit high compared to living standards in developing countries in South East Asia, like Vietnam. Therefore I tried the “free” alternatives:
+ Dynamic Code Evolution (DCE) VM
+ HotswapAgent – a derivative work from DCEVM agent
+ SpringReloaded – also a similar approach to HotswapAgent (different bytecode lib)
+ Spring Boot DevTools – not really “hotswap” classes but “quick reload/restart”, and can “refresh” the static resources (CSS, HTML, …).
Anyway, they all are based on classloader replacement and bytecode instrumentation/manipulation.
In the end, I found that it’s still okay to use a “mix” of those, they are very close to JRebel if used properly.
For instance, I use DCEVM with SpringLoaded agent for general debug hotswapping, it’s good when using with servlet containers which takes time to restart/re-deploy, like Tomcat and JBoss web (the new “Undertow”). Jetty is still good and under-rated, as usual, but I will leave it as “low-profile” rather than being acquired and become bloated.
I would recommend HotSwapAgent on IDEA users, but for local Tomcat debug I would use DCEVM with SpringLoaded:
VM Options: (either JAVA_OPTS / JPDA_OPTS / CATALINA_OPTS are all ok)
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -javaagent:/home/ducquoc/.m2/repository/org/springframework/springloaded/1.2.7.RELEASE/springloaded-1.2.7.RELEASE.jar -noverify -XXaltjvm=dcevm
Spring Boot DevTools is on its way to become “hotswap”, for now it’s a quick reload/restart and can still be used with standard JVM debug hotswap (JDWP), thus it’s still better than “nothing”, and it has potential since Spring Boot is getting popular and can actually save the time/day rather than being “intrusive” like the old SpringFramework approach.
That’s it. The slow deployment time was a counter-productive factor of Java development, but things are much better now thanks to such debugging tools.