0

我有下一个父类:

public class ListUIModel<T extends BaseModel> extends BaseModel implements List<T> {

    protected ArrayList<T> list = new ArrayList<T>();

    public ListUIModel() {
    }

    public ListUIModel(T... models) {
        list = ArraysUtil.asList(models);
    }

    //implementation of List interface...

并且有从 ListUIModel 派生的类:

public class ProducersUIModel extends ListUIModel<ProducerUIModel> {

public ProducersUIModel() {
}

public ProducersUIModel(ProducerUIModel... producers) { 
    super(producers);
}

other methods...

服务方法返回 PublicationUIModel。

此代码由 gwt 编译,当我运行 tomcat 时,我看到此警告:

29 Nov 2012 09:10:59,498: ERROR http-8443-Processor21 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/] - userProfileController: ERROR: Could not find class 'org.gwtwidgets.client.temp.TMouseListenerCollection' listed in the serialization policy file '/5C1ACC115899B7BFEC8646E55EC693E0.gwt.rpc'; your server's classpath may be misconfigured
java.lang.ClassNotFoundException: org.gwtwidgets.client.temp.TMouseListenerCollection
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1377)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1223)
    at java.lang.Class.forName0(Native Method)...

GWT 的 util CompileReport 说:

org.gwtwidgets.client.temp.TMouseListenerCollection
   Serialization status
      Instantiable
   Path
      'org.gwtwidgets.client.temp.TMouseListenerCollection' is reachable as a subtype of type 'class java.util.ArrayList<T>'
      'java.util.ArrayList<T>' is reachable from field 'list' of type 'com.xalmiento.desknet.ui.client.model.ListUIModel<T>'
      'com.xalmiento.desknet.ui.client.model.ListUIModel<com.xalmiento.desknet.ui.client.model.ProducerUIModel>' is reachable as a supertype of type 'class com.xalmiento.desknet.ui.client.model.ProducersUIModel'
      'com.xalmiento.desknet.ui.client.model.ProducersUIModel' is reachable as a subtype of type 'class com.xalmiento.desknet.ui.client.model.ProducersUIModel'

为什么 GWT 会尝试加载 TMouseListenerCollection?我使用 ArrayList(在其他地方没有),没关系。对我来说很难理解:(

我知道我可以从 .gwt.rpc 策略文件中明确排除此类。但是我如何用另一种方法解决这个问题?

谢谢。

4

1 回答 1

1

GWT compiler tries to list out all subtypes from ArrayList which are implementing IsSerializable. The solution is to try removing IsSerializable interface from TMouseListenerCollection or declare list in ListUIModel as transient ( non-serializable ) if it is not to be sent over the rpc.

于 2012-12-03T08:36:50.360 回答