Sunday, June 22, 2014

Re: Server side JSR 303 validation issues

Does your RPC declares ConstraintViolationException in its "throws" clause?

On Sunday, June 22, 2014 4:51:46 PM UTC+2, Arpit wrote:
Hi,

I get following error on throwing ConstraintViolationException from following server code.

        Validator jsr303Validator = Validation.buildDefaultValidatorFactory().getValidator();
       
Set<ConstraintViolation<UserDto>> violations = jsr303Validator.validate(userDto);
       
if (!violations.isEmpty()) {
           
Set<ConstraintViolation<?>> violationSet = new HashSet<ConstraintViolation<?>>(violations);
           
throw new ConstraintViolationException(violationSet);
       
}

com.google.gwt.user.client.rpc.SerializationException: Type 'java.util.HashSet' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = [ConstraintViolationImpl{interpolatedMessage='Invalid user name.', propertyPath=name, rootBeanClass=class c.b.a.SomeClass, messageTemplate='Invalid user name.'}

HashSet can certainly be serialized as I can throw exception with HashSet<String> but throwing exception with HashSet<ConstraintViolation<?>> is not working! Any help is appreciated. I'm using GWT 2.5.1

Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment