This looks really cool! <https://grails.slack.com/...
# questions
s
This looks really cool! https://grails.slack.com/archives/C07LCNWHG/p1727404354990749 I tried out the git repo and the create-controller command works, but it does not seem that other code changes (e.g. modifying a controller or service) are hot-swapped. I see messages about from the hotswap agent "Spring plugin initialized" after making a code change, but when I reload the page the change isn't reflected. Would this sort of change be expected to be updated by the hotswap agent? I'm also curious what the "Reloading active: true" means in the "Application Status" menu? I noticed that if I added
developmentOnly("org.springframework.boot:spring-boot-devtools")
to the build.gradle dependencies it changes from false->true, but I haven't been able to spot any reloading happening. Does the application have to be run through IntelliJ to leverage this kind of reloading? What kind of changes can be reloaded?
d
You have to make sure you run a specific jdk and install the hot swap jar in a specific place .
It does not need to be in IntelliJ
Lastly you have to have the groovyRestart file as an agent
We will be working to package them up so it’s easier to setup yourself
s
Thanks @davydotcom! I thought the sdkman commands/GitHub readme from the video did that?
I see the lib folder got cloned with the jars, and it looks like they're added to the classpath in the build.gradle
I just wanted to check that the "website" repo is supposed to hotswap controller method (in addition to create-controller) its current state. It sounds like it probably is, so I'll see if there's something wrong with the jdk or how those two jars are included when I run the project with grailsw
d
Yes it is
As demonstrated in my Video as well
s
Thank you!
I watched it a couple times, did you demo a controller method reloading? I think you only showed the create-controller methods while the app is running
d
I did demo a controller Method reloading I was pretty sure. I know I did it before I made the video . And a service reload
I have a separate short clip of a service reload
s
That looks so cool! I'm a bit stumped why it's not working on my end. I tried running on my windows box, and noticed you're running on mac so I tried it on my mac laptop too... I see the hotswap jar under ~/.sdkman/candidates/java/21.0.4-jbr/lib/hotswap/hotswap-agent.jar the java -version is the same as yours (OpenJDK 64-Bit Server VM JBR-21.0.4+8-569.1-jcef (build 21.0.4+8-b569.1, mixed mode, sharing)) If I
ps aux | grep java
after launching the app I see the JVM arguments and it also appears to be picking up the hotswap agent JAR on launch I see a bunch of messages about "not eligible for BeanPostProcessors" as well as errors from the hotswap agent XmlBeanDefinitionScannerAgent about being unable to convert .xml to classPath path. The log messages from your video go by too quickly for me to see if you get these too. Would you mind sharing?
d
I need to check Scott’s sample repo , he may be missing something from my text
🙏 1
Test*
s
By a stroke of luck I got it working: when I re-ran I started getting HibernateException: No Session found for current thread This lead me to : https://stackoverflow.com/questions/64104951/has-anyone-had-success-with-grails-4-java-11-and-using-dcevm-for-hotswapping-d which recommends disabling the hibernate plugin. I noticed that there is a hibernate plugin getting initialized. I modified hotswap-properties to disable both plugins:
Copy code
disabledPlugins=Hibernate,HibernateJakarta
I also needed to move the properties file from src/main to src/main/resources
👍 2
Would hotswap agent work for earlier grails versions? Or were there some internal changes in 7 that are needed to make it work? (e.g. a deeper dependence on spring boot vs micronaut)
d
Micronaut being the parent context prevented hot swap from working before
🙏 1
This is one major reason it’s implementation is going to shift to a plugin and not replace the parent context
s
Just out of curiosity, did you have the hibernate Jakarta exclusion, or is that something specific to my machine?
d
You have to exclude hibernate yes
s
Thank you!