服务器端的GWT违例检查会引发SerializationException [英] GWT violation check on server side throws SerializationException

查看:226
本文介绍了服务器端的GWT违例检查会引发SerializationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着gwt 2.4验证样本并将全部内容实现到我自己的App中。客户端很好。

I followed the gwt 2.4 validation sample and implemented the whole stuff into my own App. The client side works great.

    private void verifyRegistrationData(final RegistrationTO registration) throws ConstraintViolationException {
        final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
        final Set<ConstraintViolation<RegistrationTO>> violations = validator.validate(registration);

        if (violations.size() > 0) {
            final Set<ConstraintViolation<?>> temp = new HashSet<ConstraintViolation<?>>(violations);
            throw new ConstraintViolationException(temp);
        ...

但是如果我在服务器端执行同样的操作:

but if I do the same on the server side:

    public void update(final RegistrationTO registration) throws IllegalArgumentException, ConstraintViolationException, TestException {
    final Set<ConstraintViolation<RegistrationTO>> violations = validator.validate(registration);
    if (!violations.isEmpty()) {
        final Set<ConstraintViolation<?>> temp = new HashSet<ConstraintViolation<?>>(violations);
        throw new ConstraintViolationException(temp);
    }
    ...

整件事情崩溃,出现以下异常:

javax.servlet.ServletContext log:分派传入RPC调用时的异常
com.google.gwt.user.client.rpc.SerializationException:类型'org.hibernate.validator.engine.PathImpl'未包含在可由此SerializationPolicy序列化的类型集合中,或者其Class对象无法加载。为了安全起见,这种类型不会被序列化。

the whole thing crashes with the following exception:
javax.servlet.ServletContext log: Exception while dispatching incoming RPC call com.google.gwt.user.client.rpc.SerializationException: Type 'org.hibernate.validator.engine.PathImpl' 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.

这就是PathImpl看起来像hibernate-validator-4.1.0.Final-sources.jar

That's how PathImpl looks like hibernate-validator-4.1.0.Final-sources.jar

public class PathImpl implements Path, Serializable {
    private static final long serialVersionUID = 7564511574909882392L;
    ...

看起来不错(至少对我来说)

looks OK (at least to me)

我正在使用GWT 2.4,validation-api-1.0.0.GA,hibernate-validator-4.1.0.Final,gwt-servlet-deps ...

I am using GWT 2.4, validation-api-1.0.0.GA, hibernate-validator-4.1.0.Final, gwt-servlet-deps ...

预先感谢!

推荐答案

是否有显式定义的默认构造函数?即
public PathImpl(){} ?这是GWT的序列化机制所要求的;如果它不在源中,则序列化RPC响应将失败。

Is there an explicitly defined a default constructor? i.e., public PathImpl() { } ? This is required by GWT's serialization mechanism; if it isn't in the source, serializing an RPC response will fail.

这篇关于服务器端的GWT违例检查会引发SerializationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆