I am using the grails console to test my code as I’m finding it very unproductive to run even basic unit tests efficiently from STS.
Anyway, when I cut and paste the code into the console it runs fine. However when I save the code snippet as a .groovy script and then reopen it later and try and run it, it fails with a generic:
groovy.lang.MissingPropertyException: No such property: xxx for class: yyy
The script runs fine if I copy the code and paste into into a new window!
Any idea why this might be happening?
I discovered what was wrong with this and wanted to update here in case it useful for someone else.
One of my domain objects is called:
and I saved the groovy script as HierarchyNode.grooy.
As a result when the following code was executed in the console, it failed:
with this exception:
Renaming the script to not clash with the domain object resolved the issue.