I'm using GWT 2.1 in hosted mode.
The following GWT-RPC service that returns JPA annotated objects that
are NOT connected to database, produces a deserialization error in the
client side.
public TipoCable findTestTipoCable() {
TipoCable tp = new TipoCable();
tp.setId((long)1);
tp.setDescrip("Hola");
DesignacionCable dc = new DesignacionCable();
dc.setDescrip("sadfad");
dc.setTipoCable(tp);
tp.getDesignacionCables().add(dc);
return tp;
}
The object returned by the server is serialized with no errors, but
the client produces an error when tries to deserialize it.
If I remove JPA annotations from the entity classes, the
deserialization goes right.
Is this a bug?
I have observed that the the serialized string returned in each case
are slighty different:
The one from JPA annotated objects that produces the deserialization
error:
//OK['B',6,0,0,3,0,1,0,5,4,1,3,2,1,
["es.excentia.esco.data.model.TipoCable/
95382644","Hola","java.util.HashSet/
1594477813","es.excentia.esco.data.model.DesignacionCable/
3990987763","sadfad","java.lang.Long/4227064769"],0,6]
The one from the same objects without JPA annotations, that works ok.
//OK['B',6,-1,0,5,4,1,3,2,1,
["es.excentia.esco.data.model.test.TipoCable/
4254737913","Hola","java.util.HashSet/
1594477813","es.excentia.esco.data.model.test.DesignacionCable/
1472385747","sadfad","java.lang.Long/4227064769"],0,6]
Here is the error that is generated when deserializing in the client
side.
java.lang.ClassCastException: es.excentia.esco.data.model.TipoCable
cannot be cast to java.lang.Long
at
es.excentia.esco.data.model.DesignacionCable_FieldSerializer.deserialize(DesignacionCable_FieldSerializer.java:
51)
at es.excentia.esco.data.model.DesignacionCable_FieldSerializer
$Handler.deserialize(DesignacionCable_FieldSerializer.java:11)
at
com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:
91)
at
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:
108)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:
119)
at
es.excentia.esco.data.dto.Page_FieldSerializer.deserialize(Page_FieldSerializer.java:
65)
at es.excentia.esco.data.dto.Page_FieldSerializer
$Handler.deserialize(Page_FieldSerializer.java:11)
at
com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:
91)
at
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:
108)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:
119)
at
es.excentia.esco.data.model.TipoCable_FieldSerializer.deserialize(TipoCable_FieldSerializer.java:
51)
at es.excentia.esco.data.model.TipoCable_FieldSerializer
$Handler.deserialize(TipoCable_FieldSerializer.java:11)
at
com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:
91)
at
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:
108)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:
119)
at
com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.deserialize(Collection_CustomFieldSerializerBase.java:
34)
at
com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.deserialize(ArrayList_CustomFieldSerializer.java:
32)
at
com.google.gwt.user.client.rpc.core.java.util.ArrayList_FieldSerializer
$Handler.deserialize(ArrayList_FieldSerializer.java:11)
at
com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:
91)
at
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:
108)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:
119)
at
es.excentia.esco.data.dto.Page_FieldSerializer.deserialize(Page_FieldSerializer.java:
65)
at es.excentia.esco.data.dto.Page_FieldSerializer
$Handler.deserialize(Page_FieldSerializer.java:11)
at
com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:
91)
Here are the contents of the related returned classes:
@Entity
@Table(name="tipo_cable"
,schema="public"
)
public class TipoCable implements java.io.Serializable,
IsSerializable {
private static final long serialVersionUID = 1L;
private Long id;
private String descrip;
private Set<DesignacionCable> designacionCables = new
HashSet<DesignacionCable>(0);
/** default constructor */
public TipoCable() { }
@Id @GeneratedValue(strategy=IDENTITY)
@Column(name="id", nullable=false)
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name="descrip", length=100)
public String getDescrip() {
return this.descrip;
}
public void setDescrip(String descrip) {
this.descrip = descrip;
}
@OneToMany(fetch=FetchType.LAZY, mappedBy="tipoCable")
public Set<DesignacionCable> getDesignacionCables() {
return this.designacionCables;
}
public void setDesignacionCables(Set<DesignacionCable>
designacionCables) {
this.designacionCables = designacionCables;
}
}
@Entity
@Table(name="designacion_cable"
,schema="public"
)
public class DesignacionCable implements java.io.Serializable,
IsSerializable {
private static final long serialVersionUID = 1L;
private Long id;
private TipoCable tipoCable;
private String descrip;
/** default constructor */
public DesignacionCable() { }
@Id @GeneratedValue(strategy=IDENTITY)
@Column(name="id", nullable=false)
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="tipo_cable")
public TipoCable getTipoCable() {
return this.tipoCable;
}
public void setTipoCable(TipoCable tipoCable) {
this.tipoCable = tipoCable;
}
@Column(name="descrip", length=100)
public String getDescrip() {
return this.descrip;
}
public void setDescrip(String descrip) {
this.descrip = descrip;
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.