I'm trying to retrieve a default validation error-message using MessageSource. The code I'm working with uses reflection to retrieve the value of the message parameter. On a constraint that does not override the message parameter, I would like to retrieve the default error message. When I invoke the message method on the validation annotation, I get {org.hibernate.validator.constraints.NotBlank.message} (for example, for the @NotBlank annotation). I then tried to use MessageSource to get the error message like so:
String message = messageSource.getMessage(key, null, Locale.US);
I tried setting key to {org.hibernate.validator.constraints.NotBlank.message}, org.hibernate.validator.constraints.NotBlank.message (removed braces) and even org.hibernate.validator.constraints.NotBlank but I keep getting null. What am I doing wrong here?
UPDATE
A clarification. I am under the impression that Spring comes with a default message.properties file for its constraints. Am I correct in this assumption?
UPDATE
Changing the name of the question to better reflect what I was trying to do.