Grails 2.3.0 Auto-reloading not working
Asked Answered
E

5

39

I recently upgrade our project to grails 2.3.0. Everything works fine except I've been having problems with auto-reload not working whenever I make changes to our code. This include all projects artefacts - controllers, domain, services, gsps, css and javascript files.

My older versions of grails work correctly and reloads and recompile every time I make a change.

I know this question is popular and I have searched Jira, Nabble and here for days now but none of what I have found have been able to solve my problem (I've even tried to add quotes like Peter suggested in this thread http://jira.grails.org/browse/GRAILS-7936 and also this thread Grails Project Not Auto Reloading did not help).

Am currently running grails on a Macbook pro with the following settings:

  • grails version 2.3.0
  • Java version "1.7.0_17" Java(TM) SE Runtime Environment (build 1.7.0_17-b02) Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
  • Running from terminal with Textmate as IDE

Any help would be greatly appreciated.

Esdraelon answered 18/9, 2013 at 21:23 Comment(4)
try grails -reloading run-appUturn
I just tried that but it doesn't work. Auto re-compiling after save does not work either.Esdraelon
I just tried using 2.3.0 on a different machine. I created a new project. I still get the same issue. Alidad's solution seems to work when not in interactive mode on this new machine but shouldn't this be the default settings for development? Still need it to work on my mac and interactive mode. Any help would be appreciated.Esdraelon
For GRAILS-7936 see: web.archive.org/web/20140223155538/http://jira.grails.org/…Tungstic
U
50

It seems that in Grails 2.3 the reloading is no longer the default

In Grails 2.3 the reloading agent is no longer on the build system path unless you pass the -reloading flag to the grails command:

grails -reloading run-app

However, you can enable forking in your buildConfig using the following configuration:

forkConfig = [maxMemory: 1024, minMemory: 64, debug: false, maxPerm: 256] 
grails.project.fork = [    
  test: forkConfig, // configure settings for the test-app JVM    
  run: forkConfig, // configure settings for the run-app JVM    
  war: forkConfig, // configure settings for the run-war JVM    
  console: forkConfig // configure settings for the Swing console JVM ]

More information : Forked Execution and the Reloading Agent

Uturn answered 19/9, 2013 at 0:59 Comment(7)
Thats right. I should have read the documentation before upgrading (Well, I did but never got to that part). Am not using the forked JVM thats why. I had it commented out but uncommenting it got auto reloading/re-compiling working again. Thanks man.Esdraelon
Set this grails.reload.enabled = true in BuildConfigTrichocyst
Set "grails.reload.enabled = true" in BuildConfig.groovy doesn't work for me. Work only if I use "grails -reloading run-app" or comment (or disable) the fork config in BuildConfig.groovy. My Grails is 2.4.3.Nonparous
I'm using Grails 2.4.4. Although I see "Compiling 1 source files" whenever I make a change to a controller such as modifying the text that gets rendered, the change doesn't take effect at all in the browser. Any ideas?Williford
@Sofia i am also facing the same issue, have you got any solution?Vernal
@Bldesi For some reason 2.4.4 wasn't working for me. I tried going with 2.4.3 and reloading just worked right out of the box. My teammates say 2.4.4 works for them though.Williford
I have the same error using Grails 2.5.0 when changing a domain class. grails -reloading run-app, grails.reload.enabled = true, enable/disable forking all does not work for me.Curley
M
8

I am using Grails 2.4.3 and IntelliJ 13 and I found that I had to have the -reloading part at the end of the run-app command.

In other words when you edit your Run/Debug configurations, in the 'Command Line' part put run-app -reloading and NOT -reloading run-app.

I found this solution here from user longwa

Melonymelos answered 27/11, 2014 at 16:3 Comment(3)
that is funny, cause for me (upgraded to IntelliJ 14) it is the other way round again :) - I use: -reloading run-appSonnysonobuoy
Does not work for me in 2.5.0 putting reloading before or after.Curley
Attaching -reloading to the end of run-app command (with other options like -https in between) worked for me as well. I think intellij idea needs to address this issue asap.Cinquain
S
7

Grails 2.4.x maintained the same support:

grails -reloading run-app

The logs will show the status of the reload once a "watched" file changes in the file-system:

2014-09-23 00:42:02,666 [localhost-startStop-1] INFO  conf.BootStrap  - Checking for registries in system env
| Server running. Browse to http://localhost:8080/docker-registry-ui
| Compiling 1 source files.....
Soup answered 23/9, 2014 at 7:42 Comment(2)
I was getting exceptions on reloading of Controllers and Services (despite the fact that the changes are correctly reloaded). The "grails -reloading run-app" works like a charm on my Grails 2.4.3 and I dont get more exceptions.Nonparous
Controllers are not reloading automatically when I add new actions even after trying the relaoding option and with my forked tomcat enabled. I'll have to post this as a new question for grails 2.4.3Esdraelon
C
4

I was not able to fix my problem with reloading by any of the suggestions above. In my case the problem was my path, it contained a space! Took me a couple of days and half my beard but finally figured it out. My path was something like : ~/Box Sync/path/to/project. That single space in Box Sync was the hidden bad guy. I beleive it to be related to this ticket https://github.com/grails/grails-core/issues/9344.

Caledonian answered 28/5, 2015 at 18:45 Comment(3)
Thanks for your answer. I didn't think that the name of my workspace was the problem.Nigritude
Would be nice if the platform could print "paths without space not allowed" intsead of some difficult-to-troubleshoot misbehavior.Wild
Great finding!! Thanks a lot.. After 2 days of struggle I got to know this.But now happy to know the actual reason. It always show ...changed, recompiling... but actually never happendShows
I
2

I dont need run with -reloading in the command line, its problem of springloaded.jar.

replace folder springloaded in grailsHome/lib/org.springframework/springloaded with the of grails sdk 2.4.3

https://mega.co.nz/#F!INgVnboD!r7ssrFy9TiCQ50ROqxWt8g

I tested in grails 2.5.0 and 2.4.*

Itol answered 23/4, 2015 at 22:9 Comment(1)
mega folder is invalid. download grails 2.4.3 from grails official directory. and replace the springloaded folder.Rohrer

© 2022 - 2024 — McMap. All rights reserved.