【问题标题】:GWT - RPC SerializationException with class objectGWT - 带有类对象的 RPC SerializationException
【发布时间】:2017-10-31 05:10:08
【问题描述】:

我目前正在尝试使用 SyncProxy 库来测试我的应用程序的服务,以便使用 JMeter 进行负载测试。该应用程序运行良好,我在 localhost 上运行它。

我已经设法进行了一些调用,但只有当参数在哪里时

这是错误:

类型“net.gicm.ector.shared.beans.Utilisateur”未包含在 可以通过此 SerializationPolicy 序列化的类型集或 无法加载其 Class 对象。出于安全目的,此类型 不会被序列化。

这是我拨打电话的一段代码:

 final Utilisateur user = new Utilisateur();
 user.setUser("C2984");

 TableauDeBordServiceAsync tableauDeBordServiceAsync = (TableauDeBordServiceAsync) SyncProxy
          .newProxyInstance(TableauDeBordServiceAsync.class, MODULE_BASE_URL, GET_SERVICE_NAME_2);
 tableauDeBordServiceAsync.ongletRealisationListeControle(plan, user, codeSI, numStructure, synthese, colonneAtrier, ordre, numeroPagination, filtre, new AsyncCallback<List<List<String>>>() {

    @Override
    public void onFailure(Throwable caught) {
        // TODO Auto-generated method stub
        System.out.println(caught);

    }

    @Override
    public void onSuccess(List<List<String>> result) {
        // TODO Auto-generated method stub
        System.out.println(result);

    }

 });

我查看了这个帖子,并试图找出我哪里做错了:https://stackoverflow.com/a/9534704/4628136

我的类实现了Serializable 接口,有一个默认的空构造函数,并且在客户端包中。

public class Utilisateur implements Serializable {
   ...
   public Utilisateur() {
   }
   ...
}

但实际上,我在 gwt.rpc 文件中没有看到关于 Utilisateur 类的任何内容。

【问题讨论】:

  • 如果Utilisateur 聚合了不可序列化/无参数构造函数的类型,也会出现该错误。
  • 嗯,只有一个,它确实有一个无参数的构造函数,它实现了 Serializable 接口
  • Utilisateur 中的课程是否在“共享”数据包中?
  • 是的,它在“共享”包中
  • 请不要在 Stack Overflow 上发布像 paste.ofcode.org 这样的临时内容。

标签: java gwt gwt-rpc gwt-syncproxy


【解决方案1】:

我认为你需要实现

com.google.gwt.user.client.rpc.IsSerializable

你的班级会是这样的:

public class Utilisateur implements IsSerializable, Serializable {
   ...
   public Utilisateur() {
   }
   ...
}

【讨论】:

  • 我仍然有同样的错误,即使在实现IsSerializable 接口时
  • 尝试将private static final long serialVersionUID = 1L; 放入您的Utilisateurclass
  • 您的班级有Utilisateur 实习生班级参考资料吗?我的意思是,类似private MyClass myClass;?所有内部引用也必须是可序列化的
  • 不,没有
  • 能否请您发布完整的Utilisateurclass?
【解决方案2】:

确保这个类的所有属性也都被序列化了。

【讨论】:

    猜你喜欢
    • 2013-05-20
    • 2013-10-05
    • 2010-10-31
    • 1970-01-01
    • 2011-12-07
    • 1970-01-01
    • 2014-05-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多