我有下一个父级:
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政策文件中排除这个类。但我如何用另一种方法解决这个问题?
感谢。
答案 0 :(得分:1)
GWT编译器尝试列出实现IsSerializable的ArrayList中的所有子类型。解决方案是尝试从TMouseListenerCollection中删除IsSerializable接口,或者如果不通过rpc发送,则将ListUIModel中的列表声明为瞬态(不可序列化)。