Nix
Nix

Reputation: 58522

Groovy:Apparent variable xyz was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:

I am getting this "error" in an Spring Tool Suite for all of my domain classes. Its not really an error, because it compiles fine. But it's masking real compile errors, how can I get rid of it ? They are in the same package, so I dont need the import, if I add the import it says it can't find the class...

So the following code produce a red x

Groovy:Apparent variable 'ExampleB' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:

package domain.com.so;

class ExampleA {
    static belongsTo  = [exampleB: ExampleB]
    static constraints = {
    }
}

And this code produces a simpilar error:

Groovy:Apparent variable 'ExampleA' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:

package domain.com.so;

class ExampleB {
    static hasMany  = [exampleAs: ExampleA]
    static constraints = {
    }
}

Upvotes: 4

Views: 11231

Answers (2)

user800014
user800014

Reputation:

Normally when STS complains something like this I run

grails clean 

and

grails compile --refresh-dependencies

Upvotes: 8

Thomas Farvour
Thomas Farvour

Reputation: 1103

This happens quite often when I'm making changes to static members and the dynamic reloading is enabled while running the application. I find I have to delete and re-add the project to the workspace. It's almost like the metadata for the project gets in a "stuck" state of when the error occurred during run-time.

Upvotes: 1

Related Questions