Q:

Grails withForm causing error

I'm running into an issue using the code below.  I'm getting an error when I add the invalidToken handler.  I'm using grails V 2.3.4   
 withForm {
       // ready to go
    }.invalidToken {
       // bad submit
    }

blaaaa/blaaa/controller.groovy: 123: [Static type checking] - Cannot
  find matching method
  java.lang. Object#invalidToken(groovy.lang. Closure).  Please check if
  the declared type is right and if the method exists.   @ line 123,
  column 9. 
             withForm {
             ^

A:

As you can see, using @CompileStatic can cause dynamic code to fail, so you need to rework some code to be compatible.  However there is a lot of functionality in Grails that isn't compatible with @CompileStatic as it's a relatively new feature; it's only been available to use in Grails since the 2.2 release which was the first to use Groovy 2.0. 
So you'll have to rework that withForm block to be non-dynamic.  I haven't looked at the underlying code recently but my guess is you can do it, but it will be ugly and you'll wish you hadn't.  Use @CompileStatic where it makes sense (and it where it makes a difference; the performance difference for this block of code with and without it will likely be a few milliseconds). 
I haven't worked with @CompileStatic enough to be sure, but I'm pretty confident that you can always remove the annotation and the code will work; you will then have redundant casts and non-dynamic code, but it's still perfectly valid Groovy.