First time posting here.
I'm developing a JSON webservice API and I'm tring to use custom validation message with no success.
Here is my setup (focus on component involved in my problem. I also use MyBatis, jUnit...) :
- Tomcat 8.0.14
- Spring 4.1.1
- Jersey 2.13
- Jersey-spring3 2.13
- Jersey-bean-validation
- Hibernate Validator 5.0.0.Final
Bean property validation and class-level validation work fine. Now I'm trying to setup custom error validation messages.
I don't wan't to use the JSR-303 /META-INF/ValidationMessages.properties but I wan't to use a spring managed bundle.
In my applicationContext.xml, I defined :
<bean name="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="validationMessageSource">
<ref bean="messageSource" />
</property>
</bean>
<bean name="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="configuration/messages/validation" />
</bean>
I also create a /WEB-INF/classes/configuration/messages/validation_fr_FR.properties with some properties :
model.error=Modèle invalide
Now when I try to validate my Bean I get this in my logs :
15:47:14,300 DEBUG http-nio-8080-exec-2 resourceloading.PlatformResourceBundleLocator:72 - ValidationMessages not found.
15:47:45,707 DEBUG http-nio-8080-exec-2 resourceloading.PlatformResourceBundleLocator:69 - org.hibernate.validator.ValidationMessages found.
No mention to my bundle here...
In my JSON response, I get :
{model.error} (path = EventServiceAPIImpl.createOrUpdateEvent.arg0, invalidValue = fr.bz.pdcv.bean.Event@d99af88)
{model.error} is not replaced with my custom message.
I think my ReloadableResourceBundleMessageSource is overridden by Hibernate Validator default configuration. But why ?
I overload google and stackoverflow to find a solution, I didn't find anythings which can help me
Does someone encounter the same issue ?
Thank you !