Note that there are some explanatory texts on larger screens.

plurals
  1. POGWT+GXT serialization goes wrong after minor changes. But why?
    text
    copied!<p>I thought I knew GWT serialization rules, but apparently I don't. This case is just weird, I'm trying to figure it out for couple of hours, still no luck. Maybe you, guys, could lend me a hand on this one?</p> <p>First things first: the stack trace.</p> <pre><code>...blah blah blah... Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'geos.dto.common.client.Market' 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 = null at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:619) 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:44) at com.google.gwt.user.client.rpc.core.java.util.HashSet_CustomFieldSerializer.serialize(HashSet_CustomFieldSerializer.java:39) at com.google.gwt.user.client.rpc.core.java.util.HashSet_CustomFieldSerializer.serializeInstance(HashSet_CustomFieldSerializer.java:51) at com.google.gwt.user.client.rpc.core.java.util.HashSet_CustomFieldSerializer.serializeInstance(HashSet_CustomFieldSerializer.java:28) at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:740) at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:621) 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) ... 78 more </code></pre> <p>So it appears the problem lies in <code>geos.dto.common.client.Market</code>. Let's see the minimal that still can be compiled.</p> <pre><code>package geos.dto.common.client; public class Market extends RowModel&lt;Integer&gt; { public static final String ID="id"; public static final String NAME="name"; public Market() { } public Market(int id, String name) { } public String getName() { } public void setName(String name) { } } </code></pre> <p>Either I <strong>really</strong> need a vacation, or it's just fine. <strong>A LOT of DTO classes inherit from RowModel, they are working and are serialized properly, no problems there.</strong> But of course I'll show you anyway. This time some GXT stuff ahead. This class is unedited, but still fairly simple.</p> <pre><code>package geos.dto.common.client; import com.extjs.gxt.ui.client.data.BaseModelData; public class RowModel&lt;I&gt; extends BaseModelData implements IdentifiableModelData&lt;I&gt; { private I identifier; private String identifierProperty; public RowModel() { } public RowModel(String identifierProperty) { this.identifierProperty=identifierProperty; } @Override public I getIdentifier() { return identifier; } public void setIdentifier(I identifier) { this.identifier = identifier; if((identifierProperty!=null)&amp;&amp;(!identifierProperty.isEmpty())) { set(identifierProperty,identifier); } } public void setIdentifierProperty(String identifierProperty) { this.identifierProperty = identifierProperty; if(identifier!=null) { set(identifierProperty,identifier); } } public String getIdentifierProperty() { return identifierProperty; } @Override public &lt;X&gt; X set(String property, X value) { if(property.equals(identifierProperty)&amp;&amp;((identifier==null)||(!getIdentifier().equals(value)))) { setIdentifier((I)value); } return super.set(property, value); } } </code></pre> <p>Looks somewhat weird, I know, but these identifier is really important. I removed <code>toString()</code> which - in this case - returns null (because internal <code>RpcMap</code> is null, and it's null because no values are set in <code>Market</code> class). And the last piece of code, the interface implemented by <code>RowModel</code>:</p> <pre><code>package geos.dto.common.client; import com.extjs.gxt.ui.client.data.ModelData; import java.io.Serializable; public interface IdentifiableModelData&lt;I&gt; extends ModelData, Serializable { public I getIdentifier(); } </code></pre> <p>The versions are GWT 2.4.0 and GXT 2.2.5. I want to upgrade it soon, but first I want to deal with problems like this one.</p> <p>And that would be all, I think. Do you see anything I can't see? I certainly hope so! Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload