6

I've

  1. created new Grails 2.4.3 project
  2. created TestController
  3. set grails.reload.enabled = true in BuildConfig.groovy
  4. run application with grails -reloading run-app

My controller action code:

def index() {
    render "test"
}

When I change the string test to test2- I see in console (in Eclipse):

..................
|Compiling 1 source files

And after reloading page I see test2 - ok.

But when I try to add new method:

def test3() {
    render "test3"
}

I see:

error result

Why? Why there isn't even the url?

Example - action does't exist: enter image description here

Interesting thing is - when I create a whole new controller the index action of the newly created controller works...

EDIT

After a while I decided to go with spring-boot and as a matter of fact - there it's not working either. I think that springloaded is the issue here because it doesn't pick up added new method in @Controller

Xeon
  • 5,949
  • 5
  • 31
  • 52
  • Did you add view page corresponding to test3 action? – user1791574 Aug 22 '14 at 10:02
  • 1
    The `render` method overrides this behaviour (of finding some view for an action). If I had returned model then it should search for a corresponding view. But yes - I've tried this also: with the same effect. – Xeon Aug 22 '14 at 10:08
  • Im stuck here, did you find anything to solve this @Xeon ? – Vitor Hugo Sep 09 '14 at 20:08
  • 1
    Same issue, only a restart reload new actions in controllers. Changes in existing actions are reloaded right. – IsidroGH Sep 09 '14 at 21:28
  • @VitorHugo, @IsidroGH - it's `spring-loaded` issue. I've posted an answer. – Xeon Sep 10 '14 at 12:28

3 Answers3

4

I've asked the same question on github repo.

It seems that latest spring-loaded SNAPSHOT is working fine.

But it must be integrated into Grails - maybe in the next release unfortunately :(

Xeon
  • 5,949
  • 5
  • 31
  • 52
  • 1
    overwrited the old spring-loaded jar in grails-2.4.3\lib\org.springframework\springloaded\jars with the latest build and it worked, thank you Xeon. – Vitor Hugo Sep 10 '14 at 13:33
1

I took the liberty of reporting this issue to Grails.

doelleri
  • 19,232
  • 5
  • 61
  • 65
candrews
  • 1,995
  • 1
  • 16
  • 13
1

Solution that works for me:

1) Versions:

  • IDE: Intellij IDEA 14.1.3
  • JDK: jdk1.7.0_25
  • GRAILS: 2.5.0

2) On BuildConfig.groovy:

grails.reload.enabled = true
grails.project.fork = [
        test: false,
        run: false,
]

3) Originally, my code was compiled on grails 2.4.4, so I upgraded to 2.5.0. I had no problems with the version change with plugins or anything. My guess is this works because it uses later versions of spring-loaded. Steps:

  • set-grails-version 2.5.0
  • clean
  • delete directory work (just to be sure, I don't really know if this is good practice)
  • compile and/or go to number 4

4) Debug Idea with this configuration: run-app -reloading


Works perfect, no forked debug, reloading enabled, no console error after reload and all breakpoints working even after code changes!

hugoriar
  • 11
  • 1
  • I have tried the all the above steps but auto reloading not working. My environment is as below: IDE: Intellij IDEA 2016.2 JDK: jdk1.8.0_101 GRAILS: 2.5.4 – Piyush Chaudhari Oct 07 '16 at 15:51