After adding a custom Comparator to sort one of my domain models, I started getting the following exception sporadically:
groovy.lang.MissingPropertyException: No such property: name for class:
The odd thing is that the model I was attempting to sort was one of my domain models of type Transaction; however, grails was interpreting it as a generic Object. The really weird thing is that it was also interpreting my Transaction objects as generic Objects in other locations as well. After a while of debugging, I went back to the code where I started seeing the issue. I had created a private inner class for the Comparator and defined it as follows:
private class TransactionComparator<Transaction> extends Comparator<Transaction>
My mistake was including the generic declaration at the class level. This would be invalid in normal Java syntax; however, groovy was compiling another class named Transaction, but it was casting it to a generic Object. Once I fixed my class to the following, the issue went away:
private class TransactionComparator extends Comparator<Transaction>
I hope this helps others that run into similar issues.