Hi, I have a following spring config where I explicitly create LocalValidatorFactoryBean using my own ValidationMessageSource. I have Hibernate Validator 4.1 in my class path.
However I noticed that the LocalValidatorFactoryBean is being created twice by hitting a debug in classes "afterPropertiesSet" method. The first time is for the explicite bean I created, however following that the same class is instantiated implicitly again by DefaultListableBeanFactory class - obviously this time with no validationMessageSource. Therefore it seems that when Spring does make use of the LocalValidatorFactoryBean its using the one with the default Hibernates messagesource rather than the one I have specified.Code:<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basenames"> <list> <value>ValidatorMsgID</value> </list> </property> </bean> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> <property name="validationMessageSource" ref="messageSource"/> </bean> <bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor"/>
Ok, looking into this a bit further its seems that this is caused by "mvc:annotation-driven" I have in the spring config! Any pointers would still help
Any pointers would really help
thanks


Reply With Quote