When I run my grails application using embedded jetty server(tomcat for grails 1.2), I can make changes to my controllers, services and other java files on-the-fly at runtime without restarting the application. How can I achieve the same functionality on my application deployed on Tomcat(or any server) for that matter. I have observed the exploded war folder under webapps has gsp files but not the groovy files.
+3
A:
When you package your application as a WAR, the Groovy files are compiled to Java bytecode (.class files) and included in the WAR. The hot swapping of files at runtime is not suitable for production use due to memory leaks.
Eric Hauser
2010-05-03 20:55:42
+1
A:
Completing Eric's answer, you cannot change on the fly the source code in production environment. However, if you really want to modify your code in live you can:
- Change the groovy class, compile it, replace the .class file in the exploded war folder and restart tomcat (I know, I know, it's painful but I don't know a better way)
- For gsp files, there is a trick. add to your Config.groovy file the following property :
grails.gsp.enable.reload=true
. This will allow you to change on the fly your gsp file. Be careful because it will hurt performance. See here for details
fabien7474
2010-05-04 08:26:27