-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: javax.validation.ConstraintDefinitionException: HV000074
PostPosted: Tue Nov 27, 2012 1:23 pm 
Newbie

Joined: Tue Nov 27, 2012 1:03 pm
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: javax.validation.ConstraintDefinitionException: HV000074
PostPosted: Tue Nov 27, 2012 8:05 pm 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
There's a typo in the "payload" attribute of your constraint, you got "palyload" instead.

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: javax.validation.ConstraintDefinitionException: HV000074
PostPosted: Wed Nov 28, 2012 11:07 am 
Newbie

Joined: Tue Nov 27, 2012 1:03 pm
Posts: 2
OOOPPPSS! Oh my god, I can't believe I did it!
I tested and it is working fine.
Thank you very much my friend, god bless you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.