5


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.

Onkar Salvi
  • 151
  • 1
  • 10

2 Answers2

4

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.

Onkar Salvi
  • 151
  • 1
  • 10
  • Does HA with Tomcat and multiple projects really work for you? I have [this issue](https://github.com/HotswapProjects/HotswapAgent/issues/382) with static classes. I have prepared a [example project](https://github.com/achimmihca/HotSwapAgent-LinkageError-Tomcat) to reproduce. Would you mind to check if its config is correct? – mihca Jan 22 '21 at 08:54
2

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

edudant
  • 719
  • 6
  • 6