I have next parent-class:
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...
And have class derived from ListUIModel:
public class ProducersUIModel extends ListUIModel<ProducerUIModel> {
public ProducersUIModel() {
}
public ProducersUIModel(ProducerUIModel... producers) {
super(producers);
}
other methods...
Service method returns PublicationUIModel.
This code is compiled by gwt, and when I run the tomcat, I see this warning:
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)...
And GWT’s util CompileReport says:
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'
Why GWT tries to load TMouseListenerCollection? I use ArrayList(without in other places) and all right. It’s till difficult to understand for me 🙁
I know that I can explicity exclude this class from .gwt.rpc policy file. But how I resolve this issue with another approach?
Thanks.
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.