So I found this library called hotswapagent, and it enables you to do hotswapping for an application which you deploy on an application container. It works beautifully with the XML configurations and the class files too, but for two cases :
In some WARs, you can use another jar for 'utils' and keep it as a seperate dependency for the main WAR. How do I replace class files in my jar that's a dependency of my main WAR?
How do I configure Web Application Containers like Tomcat/Weblogic to accept changes in internal jars at runtime?
Create a hotswap-agent.properties file in the resources directory (e.g:
src/main/resources
) of your main module. In that file, setextraClasspath
to the target class folder of utils module. It would look something like this:extraClasspath=<path to utils module>/target/classes
Here's a sample
hotswap-agent.properties
file with default values and comments explaining each variable: https://github.com/HotswapProjects/HotswapAgent/blob/master/hotswap-agent-core/src/main/resources/hotswap-agent.propertiesNow when you deploy your web application, HotSwapAgent loads the extra classes onto the classpath, and you will be able to hot swap code in them. I'm assuming you would not need to perform the second part in the question if you can already reload classes using HotSwapAgent.