user
02/07/2025, 6:03 PMFile /full/path/to/Request.groovy changed, recompiling...
But when I try to do this with the GroovyConsole, it is clear it continues to use the old class.
If I try to add a new controller with the default webapp created by Grails Forge, reloading the page shows the new controller class in the list of controllers. But clicking on it gives a 404 error.
Am I doing something wrong? Is there additional configuration I should be adding?user
02/10/2025, 3:25 PMuser
02/10/2025, 3:27 PMJames Fredley
02/10/2025, 8:23 PMJames Fredley
02/10/2025, 8:29 PMuser
02/10/2025, 9:20 PMjvmArgs for bootRun specified a few lines later that I didn't have in my build.gradle. I added these lines:
bootRun {
jvmArgs(
'-XX:+AllowEnhancedClassRedefinition',
'-XX:HotswapAgent=fatjar')
}
I omitted the -javaagent:lib/groovyReset.jar line that the build.gradle you pointed to had, since it caused an error. I'm guessing this is the groovy jar that @davydotcom references in https://github.com/grails/grails-core/issues/13669 (which I just now found, but which sounds like what I was seeing as well).gaolei
03/14/2025, 3:08 PMbootRun {
jvmArgs(
'-XX:+AllowEnhancedClassRedefinition',
'-DautoHotswap=true',
'-XX:HotswapAgent=fatjar')
}
This will work, but it throws bunch of errors like:
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.hotswap.agent.plugin.spring.reload.SpringChangedReloadCommand.executeCommand(SpringChangedReloadCommand.java:54)
at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:43)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.invokeBeanFactoryPostProcessors(SpringBeanReload.java:655)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.doReload(SpringBeanReload.java:296)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.reload(SpringBeanReload.java:259)
at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.doReload(SpringChangedAgent.java:204)
at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.reloadAll(SpringChangedAgent.java:192)
at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.reload(SpringChangedAgent.java:143)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 3 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.invokePostProcessorRegistrationDelegate(SpringBeanReload.java:666)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.invokeBeanFactoryPostProcessors(SpringBeanReload.java:646)
... 9 more
but it works