I am following the exact instructions of Chapter3 - Creating custom constraints of the Hibernate Validator JSR 303 Reference Implementation Guide to create a custom contraint in a Spring MVC web app and I get the javax.validation.ConstraintDefinitionException: HV000074: web.utils.validator.Sin contains Constraint annotation, but does not contain a payload parameter.
STACK TRACE: javax.validation.ConstraintDefinitionException: HV000074: web.utils.validator.Sin contains Constraint annotation, but does not contain a payload parameter. at org.hibernate.validator.internal.metadata.core.ConstraintHelper.assertPayloadParameterExists(ConstraintHelper.java:346) at org.hibernate.validator.internal.metadata.core.ConstraintHelper.isConstraintAnnotation(ConstraintHelper.java:327) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraintAnnotations(AnnotationMetaDataProvider.java:402) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraints(AnnotationMetaDataProvider.java:366) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findPropertyMetaData(AnnotationMetaDataProvider.java:219) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getPropertyMetaData(AnnotationMetaDataProvider.java:213) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.retrieveBeanConfiguration(AnnotationMetaDataProvider.java:126) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfiguration(AnnotationMetaDataProvider.java:114) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfigurationForHierarchy(AnnotationMetaDataProvider.java:96) at org.hibernate.validator.internal.metadata.BeanMetaDataManager.createBeanMetaData(BeanMetaDataManager.java:160) at org.hibernate.validator.internal.metadata.BeanMetaDataManager.getBeanMetaData(BeanMetaDataManager.java:128) at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:292) at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:133) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:101) at org.springframework.validation.DataBinder.validate(DataBinder.java:722)
Sin.java content is:
import static java.lang.annotation.ElementType.*; import static java.lang.annotation.RetentionPolicy.*; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; import javax.validation.Constraint; import javax.validation.Payload;
@Target({METHOD, FIELD, ANNOTATION_TYPE}) @Retention(RUNTIME) @Constraint(validatedBy=SinValidator.class) @Documented public @interface Sin { String message() default "{Sin.message}"; Class<?>[] groups() default {}; Class<? extends Payload>[] palyload() default {}; }
SinValidator.java is: import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; public class SinValidator implements ConstraintValidator<Sin, String> { @SuppressWarnings("unused") private Sin constraintAnnotation; @Override public void initialize(Sin constraintAnnotation) { this.constraintAnnotation = constraintAnnotation; } @Override public boolean isValid(String sinNumber, ConstraintValidatorContext constraintContext) { //it is recommended to return true for null values, to check for nulls use @NotNull if (sinNumber == null) { return true; } return checkSinAlgorithm(sinNumber); }
The jars in web-inf/lib are: aopalliance-1.0.jar cglib-nodep-2.2.jar hibernate-validator-4.3.0.Final.jar hibernate-validator-annotation-processor-4.3.0.Final.jar javax.inject-1.jar jboss-logging-3.1.0.CR2.jar jcl-over-slf4j-1.6.1.jar jstl-1.2.jar junit-4.7.jar log4j-1.2.16.jar org.springframework.aop-3.1.3.RELEASE.jar org.springframework.asm-3.1.3.RELEASE.jar org.springframework.beans-3.1.3.RELEASE.jar org.springframework.context-3.1.3.RELEASE.jar org.springframework.context.support-3.1.3.RELEASE.jar org.springframework.core-3.1.3.RELEASE.jar org.springframework.expression-3.1.3.RELEASE.jar org.springframework.test-3.1.3.RELEASE.jar org.springframework.transaction-3.1.3.RELEASE.jar org.springframework.web-3.1.3.RELEASE.jar slf4j-api-1.6.1.jar slf4j-log4j12-1.6.1.jar spring-security-acl-3.1.3.RELEASE.jar spring-security-config-3.1.3.RELEASE.jar spring-security-core-3.1.3.RELEASE.jar spring-security-taglibs-3.1.3.RELEASE.jar spring-security-web-3.1.3.RELEASE.jar spring-webmvc-3.1.3.BUILD-20120707.183226-1.jar validation-api-1.0.0.GA.jar
Is there a problem somewhere? Thanks
|