RPC Serialization of an Interface..

86 views
Skip to first unread message

Viktor

unread,
Mar 9, 2012, 4:33:35 AM3/9/12
to Google Web Toolkit
Hi all,

for my application i need to parse custom objects with the simple-xml
framework from the server side. This works fine. But if a make a rpc
call from the client side to geht the Objects i get this Exception:

[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'Media'
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 =
Media@12342d9
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.ArrayList_CustomFieldSerializer.serialize(ArrayList_CustomFieldSerializer.java:
39)
....

The Media Class look like this:

public class Media implements Serializable {

/**
*
*/
private static final long serialVersionUID = -4959495795968436441L;

public Media() {
}

@Attribute(required=false, name="condition")
private String conditionText = null;

@Attribute(required=false, name="conditiontype")
private Executable.Type conditionType = null;

@Attribute(required=true)
private String src = null;

@Attribute(required=true)
private String type = null;

@Attribute(required=false)
private String name = null;

@Element(required=false)
private Condition condition = null;

public String getSource()
{
return src;
}

public void setSource(String source)
{
this.src = source;
}

public String getType()
{
return type;
}

public void setType(String type)
{
this.type = type;
}

public void setConditionText(String conditionText) {
this.conditionText = conditionText;
}

public String getConditionText() {
return conditionText;
}

public void setConditionTypeText(Executable.Type conditionType) {
this.conditionType = conditionType;
}

public Executable.Type getConditionType() {
return conditionType;
}

public void setCondition(Condition condition) {
this.condition = condition;
}

public Condition getCondition() {
return condition;
}

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}

@Commit
public void createCondition() {
if (getConditionType()!=null && getConditionText()!=null)
setCondition(ConditionFactory.createCondition(getConditionType(),
getConditionText()));
}

Executable and Condition are Interfaces.. i guess that is the problem,
because a interface couldn't implement Serializable. Is there a way to
put these interfaces trough rpc? or is there a workaround?

thanks and greetings
Viktor

Viktor

unread,
Mar 12, 2012, 7:33:29 AM3/12/12
to google-we...@googlegroups.com
no suggestions? mh then i should use classes instead of this interfaces..

Alex Dobjanschi

unread,
Mar 13, 2012, 5:09:31 AM3/13/12
to google-we...@googlegroups.com
try to use classes first, but you can definitely use interfaces. there are a couple of considerations:
1 interfaces must extend Serializable
2 those interfaces must be found by gwt rpc generator, so place them in one of the source imports of gwt module
3 implementations of these interfaces must also be visible to gwt rpc generator - that means, also be included in a visible package - along with the usual serialization requirements

Saik0

unread,
Mar 14, 2012, 6:29:00 AM3/14/12
to google-we...@googlegroups.com
Hi and thanks for your reply.

i've investigated your suggestions and must say it's more complex as i thought. Some Interfaces go'es through the rpc serialization, others not. The problem is that i have some enum's in my sources and rpc don't accept them. I'm currently redesign my model and let you know if it works. ^^

greetings
Reply all
Reply to author
Forward
0 new messages