haxx qua non

Grails standalone classes need package

by jja on

I was reminded again today that standalone classes in Grails must belong to a package. That is, a class in src/groovy or src/java needs to be in a package. For example:

file: src/groovy/mypackage/MyClass.groovy
package mypackage

class MyClass { ... }

If the class is without a package (appearing as src/groovy/MyClass.groovy), it will compile correctly but no Grails classes (like your controller or service) will be able to find it, generating an org.codehaus.groovy.control.MultipleCompilationErrorsException with the message unable to resolve class MyClass.

(comments are closed)