I just spent a couple hours trying to figure out why my Grails views wouldn’t match up with my domain.
This started out when I decided that I wanted to simplify my domain model and remove an item, DependencyVersion, from the middle of the hierarchy. This required the removal of the domain object and the update of higher and lower levels to fill in the gap. I am still in the early phases and haven’t started customizing my views much so the easiest thing to do (for me at least since I am a newbie to Grails – there may be a better way – speak up gurus) was to blow away the domain object, the test object, all the controllers, and all the views. I then ran my script, that simply called “grails generate-all X” for each domain object in my project, and generated new views. I then started my server, only to be greeted by a message trickling up from Hibernate regarding the DependencyVersion class being missing but being used in an association.
My domain no longer had this class. I could even do a text search on the entire project for “DependencyVersion” and get no results. I tried everything I could think of – I won’t list it all here – but finally found out that the actual bug was resulting from grails caching the build and not updating it properly. When you run “grails generate-all X” it builds the domain classes and places them in the Documents and Settings folder. In my case, this resulted in my project being built here: C:\Documents and Settings\jmcdonald\.grails\1.0-RC4\projects.
I blew this folder away, ran my script again, and Voila!, it worked. So am I missing something or is this a bug in Grails? I am very new to Grails and am thinking there is probably an explanation…