In my app I have a grails domain class Student. I also have a few classes in src.java originally written in plain java.
In one of those classes in some method I am trying to get a collection of students like this:
this.students = new ArrayList<Student>(Student.findAll());
Grails package is imported, intellij doesn't complain, however I get foolwing error while trying to compile.
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[groovyc] Compile error during compilation with javac.
[groovyc] F:\path\ProjectName\src\java\grb\StudentSchedule.java:58: error: cannot find symbol
[groovyc] this.students = new ArrayList<Student>(Student.findAll());
[groovyc] ^
[groovyc] symbol: method findAll()
[groovyc] location: class Student
I have been also trying different methods, on Student, but all give me the same error - cannot find symbol.
findAll()is dynamically added by Grails to all domain classes. So calling the method relies on Groovy's dynamic dispatch to find the method and then execute it. Because the method doesn't exist in the class itself, you can't call it directly from Java.