Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HotSwapAgent doesn't reload resource files on change #252

Closed
ahmedak opened this issue Jun 21, 2018 · 6 comments
Closed

HotSwapAgent doesn't reload resource files on change #252

ahmedak opened this issue Jun 21, 2018 · 6 comments

Comments

@ahmedak
Copy link
Contributor

ahmedak commented Jun 21, 2018

My setup:

Software Version
JDK 1.8.0_144
DCEVM 8u144
HA 1.1.0-SNAPSHOT
Tomcat 7.0.5

VM arguments in CATALINA_OPTS is

agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
-XXaltjvm=dcevm -javaagent:D:\hotswap\hotswap-agent-1.1.0-SNAPSHOT.jar 
-XX:TraceRedefineClasses=1

watchResources in hotswap-agent.properties is set as:

D:/workspace/services-project1/src/main/resources; \
D:/workspace/services-project2/src/main/resources; \
...

I'm running my web application on a standalone Tomcat server, and debugging via Eclipse. Class redefinition works great, and has been a huge time saver.

In case of resource files, I see messages on the console like

HOTSWAP AGENT: 18:21:40.952 INFO (org.hotswap.agent.watch.nio.TreeWatcherNIO) - Registering 
directory target D:\workspace\services-project1\src\main\resources via watched: D:\workspace\
services-project1\src\main\resources

But resource files like .properties and .xml files don't reload on change. Please help me figure out what's going wrong.

@theigl
Copy link
Contributor

theigl commented Jul 10, 2018

I had a similar issue in my Spring Boot app. For some reason, it worked when I added my resource folder to the classpath like this:

extraClasspath=$MY_PROJECT_ROOT/src/main/resources;

@skybber
Copy link
Contributor

skybber commented Jul 24, 2018

If the .properties or .xml file are configuration of your application (not Spring etc.), then don't expect it will be reloaded - there must be additional supporting mechanism like clear already read configuration structures etc. What kind of .properties .xml are you meaning?

@ahmedak
Copy link
Contributor Author

ahmedak commented Jul 24, 2018

I'm trying to hotswap messages.properties, and xml files which have validator groups, of the Spring application

@privatejava
Copy link

privatejava commented Aug 7, 2018

I too have this issue in my simple Spring Boot Application.
My commandline args for running application:

# mvn spring-boot:run -Dspring-boot.run.jvmArguments='-XXaltjvm=dcevm -javaagent:$HOTSWAP_LIB/hotswap-agent-1.3.0.jar=autoHotswap=true'

And my hotswap-agent.properties is like below

extraClasspath=src/main/resources, target/classes
watchResources=src/main/resources
disabledPlugins=
autoHotswap=true
spring.basePackagePrefix=
LOGGER=debug

I can see in the log

Registering resource listener on classpath URI HOTSWAP AGENT: 18:03:51.745 DEBUG (org.hotswap.agent.annotation.handler.WatchHandler) - Registering resource listener on classpath URI file:/home/ngm/NetBeansProjects/ocr/src/main/resources/
HOTSWAP AGENT: 18:03:51.747 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Registering directory  /home/ngm/NetBeansProjects/ocr/src/main/resources
HOTSWAP AGENT: 18:03:51.756 DEBUG (org.hotswap.agent.annotation.handler.WatchHandler) - Registering resource listener on classpath URI file:/home/ngm/NetBeansProjects/ocr/target/classes/
HOTSWAP AGENT: 18:03:51.757 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Registering directory  /home/ngm/NetBeansProjects/ocr/target/classes

and when i do any edits on my static files i get

HOTSWAP AGENT: 18:04:07.653 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Watch event 'ENTRY_MODIFY' on '/home/ngm/NetBeansProjects/ocr/src/main/resources/templates/index.html' --> index.html
HOTSWAP AGENT: 18:04:07.659 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Watch event 'ENTRY_MODIFY' on '/home/ngm/NetBeansProjects/ocr/target/classes/templates/index.html' --> index.html
HOTSWAP AGENT: 18:04:07.659 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Watch event 'ENTRY_MODIFY' on '/home/ngm/NetBeansProjects/ocr/target/classes/templates/index.html' --> index.html

So , I guess watching the resources are working but when we start to refresh the page to see the updated index.html it is still showing same old one.

Thanks

@privatejava
Copy link

privatejava commented Aug 8, 2018

I think i found the resources are working back again. I used netbeans to do this . The commandline that nebeans used was :

cd /home/ngm/NetBeansProjects/ocr; JAVA_HOME=/usr/lib/jvm/java-8-oracle /home/ngm/netbeans-8.1/java/maven/bin/mvn "-Dexec.args=-XXaltjvm=dcevm -javaagent:/home/ngm/Downloads/hotswap-agent-1.3.0.jar=autoHotswap=true -classpath %classpath np.com.ngopal.ocr.OcrApplication" -Dexec.executable=/usr/lib/jvm/java-8-oracle/bin/java org.codehaus.mojo:exec-maven-plugin:1.5.0:exec

After i changed the index.html i got

HOTSWAP AGENT: 11:40:49.043 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Watch event 'ENTRY_MODIFY' on '/home/ngm/NetBeansProjects/ocr/src/main/resources/templates/index.html' --> index.html
HOTSWAP AGENT: 11:40:49.051 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Watch event 'ENTRY_MODIFY' on '/home/ngm/NetBeansProjects/ocr/target/classes/templates/index.html' --> index.html
HOTSWAP AGENT: 11:40:49.051 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Watch event 'ENTRY_MODIFY' on '/home/ngm/NetBeansProjects/ocr/target/classes/templates/index.html' --> index.html

and it quickly updated so fast and I am loving it. It was not working before but now it is working. I don't know why.
May be i had deleted /target directory to clean and build it as fresh.

@ahmedak
Copy link
Contributor Author

ahmedak commented Mar 8, 2021

Thanks @privatejava!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants