Serialization Error.... why??????

40 views
Skip to first unread message

francescoNemesi

unread,
Dec 8, 2011, 5:47:42 AM12/8/11
to Google Web Toolkit
Hi,

when serializing an ArrayList of the bean below I get the following
error

Caused by: com.google.gwt.user.client.rpc.SerializationException: Type
'xxxxxxx.CurrentLevel' 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.: instance = xxxxxxx.CurrentLevel@1d008f5
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:
615)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:
126)
at
com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.serialize(Collection_CustomFieldSerializerBase.java:
45)
at
com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serialize(ArrayList_CustomFieldSerializer.java:
40)
at
com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serializeInstance(ArrayList_CustomFieldSerializer.java:
50)
at
com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serializeInstance(ArrayList_CustomFieldSerializer.java:
28)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:
736)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:
617)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:
126)
at
com.extjs.gxt.ui.client.data.RpcMap_CustomFieldSerializer.serialize(RpcMap_CustomFieldSerializer.java:
35)

Can anyone explain why? It is straightforward with only Integers and
Stings.

Thank You


import java.io.Serializable;

public class CurrentLevel implements Serializable{

private static final long serialVersionUID = -7742663738169565261L;

private String value;

private Integer levelNumber;

private String columnName;

private String columnFormat;

private String columnType;

public CurrentLevel() {
}

public CurrentLevel(String columnName, String columnFormat, String
columnType, String value) {
setColumnName(columnName);
setColumnFormat(columnFormat);
setColumnType(columnType);
setValue(value);
}

public CurrentLevel(String columnName, String columnFormat, String
columnType, String value,Integer levelNumber) {
this(columnName,columnFormat,columnType,value);
setLevelNumber(levelNumber);
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public Integer getLevelNumber() {
return levelNumber;
}

public void setLevelNumber(Integer levelNumber) {
this.levelNumber = levelNumber;
}

public String getColumnName() {
return columnName;
}

public void setColumnName(String columnName) {
this.columnName = columnName;
}

public String getColumnFormat() {
return columnFormat;
}

public void setColumnFormat(String columnFormat) {
this.columnFormat = columnFormat;
}

public String getColumnType() {
return columnType;
}

public void setColumnType(String columnType) {
this.columnType = columnType;
}

}

Jens

unread,
Dec 8, 2011, 6:07:22 AM12/8/11
to google-we...@googlegroups.com
Seems like your serialization policy file on your server is outdated (thats the <hashcode>.rpc file in your generated js folder, which should be available to the server and always be up-to-date). Do you use an external server? If so, redeploy your app. If you use the build-in Jetty server you may need to hit the "Reload Web Server" Button in Eclipse.

I mostly see this exception when I modify/create serializable classes and then first redeploy to external server and then reload dev mode. That way I deploy an outdated policy file and when reloading dev mode a new one will be generated and I have to redeploy again. So you should always reload dev mode first and then redeploy.

-- J.

francescoNemesi

unread,
Dec 8, 2011, 6:18:32 AM12/8/11
to Google Web Toolkit
Thanks for your reply,

I am in dev mode with the internal Jetty.... I deleted all .rpc files,
but the problem persists...

Alan Chaney

unread,
Dec 8, 2011, 9:40:56 AM12/8/11
to google-we...@googlegroups.com
Looks like you don't have a default constructor. I believe you must
provide one for GWT to be able to serialize your objects.

Maybe you should look at:

http://java.sun.com/developer/technicalArticles/Programming/serialization/
and also the GWT developer guide.

I find it useful to create unit tests that confirm that objects will
serialize properly, because its really easy to overlook something (eg no
default constructor, mismatched getter/setter signature, final fields
etc etc.)

HTH

Alan

Reply all
Reply to author
Forward
0 new messages