Grails 2.2
So this should be pretty easy, however I am constantly getting the same error message:
Class java.lang.IllegalArgumentException
Message No enum constant myPackageName.RequestType.Banner
Here is my class:
public enum RequestType {
BANNER("Banner"), OTHER("Other")
final String value
RequestType(String value) { this.value = value }
String toString() { value }
}
This is driving me up the wall!!
Edit: Stacktrace
No enum constant myPackageName.RequestType.Banner. Stacktrace follows:
java.lang.IllegalArgumentException: No enum constant myPackageName.RequestType.Banner
at java.lang.Enum.valueOf(Enum.java:236)
at org.grails.datastore.gorm.GormStaticApi.methodMissing(GormStaticApi.groovy:108)
at ysuprojects.ProjectService.viewableProjects(ProjectService.groovy:115)
at ysuprojects.ProjectService.getIndexModel(ProjectService.groovy:422)
at ysuprojects.ProjectController.index(ProjectController.groovy:25)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Here is how it is used in the class
class Project {
...
RequestType requestType
...
}
Ok – so here is what happened.
I switched from using a
Stringto using anEnum. The existing database had"Banner"in the field, which was causing this error. I changed the field to"BANNER"and I no longer receive this error.Grails was attempting to do
Enum.valueOf(RequestType, "Banner")