Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hot Swap agent Configuration for multi module project


I need help in configuring hotswap agent in my project for hot deploying class files.
In my project we have project setup like below :

WebProject (war)
|
|_ _ Service Project(jar)


Service project is used as a jar file in web project. So whenever I do changes in a java file inside service project i want hotswap agent to reload/replace its class file with the latest one without the need of deploying the entire project again.

I have downloaded dcevm(dynamic code evolution vm) for jdk 1.7.51 and hotswap-agent.jar file as well and also done eclipse configuration. Whenever I do changes in WebProject's .java, .properties files it reloads it automatically without deploying the application again. Now I just want to configure my hotswap agent in such a way that If i am doing changes in java file inside service project which is used as a jar file inside Web Project, it should reload that .class file or .jar file again.

Do I need to add one more hotswap-agent.properties file in resource folder of service project? Currently i have added it in resource folder of web project.

Any help is very much appreciated.

like image 765
Onkar Salvi Avatar asked Sep 06 '15 15:09

Onkar Salvi


People also ask

What is hot swap classes?

Documentation. Print. Java IDEs and VMs support a feature called HotSwapping. It allows you to update the version of a class while the virtual machine is running, without needing to redeploy the webapp, restart, or otherwise interrupt your debugging session.


2 Answers

I have configured hot swap agent for multi module project. In Web project i have added hotswap-agent.properties file. In hotswap-agent.properties file added path to the service projects target directory like this

extraClasspath=D:/Sample/serviceproject/target/classes

and now it is reloading files from above mentioned directory.

like image 80
Onkar Salvi Avatar answered Oct 17 '22 00:10

Onkar Salvi


Configuration file hotswap-agent.properties is loaded at runtime from classpath root (i.e. WEB-INF/classes for webapp project). If you have standard maven directory layout, put it into src/main/resources.

Use extraClasspath property as described in hotswap-agent.properties:

# Add a directory prior to application classpath (load classes and resources).
#
# This may be useful for example in multi module maven project to load class changes from upstream project
# classes. Set extraClasspath to upstream project compiler output and .class file will have precedence to
# classes from built JAR file.
extraClasspath=

Example with maven layout:

extraClasspath=_PATH_TO_Service_Project_/target/classes

like image 44
edudant Avatar answered Oct 16 '22 23:10

edudant