Hardy Ferentschik edited a comment on Bug HV-655

As I said, I'm not completely sure about conditions, I have problems reproducing it (I suspect our development environment is different from testing environment) and I'm trying to guess what happened from logs of our testing environment. I will try to write down all details I know:

  • We are using Spring validator factory bean. I don't think it's important, but here is the validator initializing code:
    StaticContextAccessor.getApplicationContext().getBean("validatorFactory", LocalValidatorFactoryBean.class).getValidator()
  • It happens when the validator is called directly in our code:
    validator.validateValue(bean.getClass(), propertyName, propertyValue, groups);
  • I think (however I'm not sure) that one of the failing cases is this:
    bean.getClass() = SomeComplexType, propertyName="orders[0].request.amount" where orders is of type List<SomeOtherComplexType>, propertyValue=null, groups=SomeNonDefaultGroup
    
  • I suspect the problem is in that generic list
  • Right now I'm trying workaround - instead of validating nested property I resolve the "request" property myself and validate amount against it. It exludes the generic list from processing and I think it works, but I get wrong paths in constraint validation, but that's another story.

This is all I know (sorry for obfuscation, security here is very tight), I hope it will be helpful. The stacktrace of typical failure is this

Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl incompatible with java.lang.Class
	at org.hibernate.validator.internal.engine.ValidatorImpl.collectMetaConstraintsForPath(ValidatorImpl.java:1176)
	at org.hibernate.validator.internal.engine.ValidatorImpl.validateValueInContext(ValidatorImpl.java:671)
	at org.hibernate.validator.internal.engine.ValidatorImpl.validateValue(ValidatorImpl.java:169)
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira