Hi,
I'm getting a weird exception in DefaultConstraintEvaluator.evaluateConstraints() line 114 (Grails 2.5.0):
protected Map<String, Constrained> evaluateConstraints(
final Class<?> theClass, GrailsDomainClassProperty[] properties, boolean defaultNullable) {
boolean javaEntity = theClass.isAnnotationPresent(Entity.class);
LinkedList<?> classChain = getSuperClassChain(theClass);
Class<?> clazz;
ConstrainedPropertyBuilder delegate = new ConstrainedPropertyBuilder(theClass);
// Evaluate all the constraints closures in the inheritance chain
for (Object aClassChain : classChain) {
clazz = (Class<?>) aClassChain;
Closure<?> c = (Closure<?>) GrailsClassUtils.getStaticFieldValue(clazz, ConstraintsEvaluator.PROPERTY_NAME);
ClassCastException: java.util.Collections$UnmodifiableMap cannot be cast to groovy.lang.Closure
I have a hierarchy of beans annotated with @Validateable
For the first 2 classes in the classChain, the 'constraints' property of the class returns a Closure, as expected. However, for the final class in the class hierarchy, the field is instead an UnmodifiableMap containing entries of type <String,ConstrainedProperty>.
I have tried to reproduce the problem in a small sample-project but in that, it works. I haven't managed to find out what I need to do, to intentionally break it.
I have tried cleaning and re-compiling countless times, I have tried tweaking classes and included plugins, but so far no result - I'm stuck.
NB: In case it makes a difference, the constraint-evaluation is triggered from within the "fields" plugin when it tries to render an <f:display/> tag.
Does anyone have any clue why the 'constraints' property of a class might be seen as a Map of ConstrainedProperty entries?
Kind regards,
--Tim