rpc serialization problem

330 views
Skip to first unread message

mike

unread,
Aug 4, 2009, 10:52:57 PM8/4/09
to Google Web Toolkit
I have a simple one-to-many betwen two entities. The parent entity
uses List to contain the child entities. I am able to persist these
entities in the datastore without problems.

However, when reading a root entity at the server, I get:

rpc.SerializationException: Type 'org.datanucleus.sco.backed.List' was
not included in the set of types which can be serialized...

The entities are successfully read from the datastore, but something
in Datanucleus doesn't build the List correctly.

Has anyone found a workaround for this serialization problem.

Thanks

GWT 1.7 GAE 1.2.2

jvor...@googlemail.com

unread,
Sep 2, 2009, 5:35:04 AM9/2/09
to Google Web Toolkit
Hallo,
i have the same problem.
List (GWT) can not be used in DataNuceleus.

Can every one help pleas!
THX

Chris Lowe

unread,
Sep 3, 2009, 9:36:52 AM9/3/09
to Google Web Toolkit
Are the List fields on your objects specified in terms of interfaces?
GWT RPC needs to know as much about your objects at compile time,
could you try using a concrete class instead - preferably ArrayList?

It sounds like you're trying to serialize ORM objects directly, is
that right? I don't know much about Data Nucleus and whether or not
it dynamically enhances entity objects under its control with proxies
etc. My experience is with Hibernate which usually does add something
to a class, so serializing entities directly is strongly discouraged -
either the entity objects have to be filtered of the Hibernate
"extras", or values copied into DTOs.

On Sep 2, 10:35 am, "jvoro...@googlemail.com"

Angel

unread,
Sep 22, 2009, 5:43:14 AM9/22/09
to Google Web Toolkit
i have the same problem

Benjamin

unread,
Oct 6, 2009, 4:50:09 PM10/6/09
to Google Web Toolkit
I'm struggeling with this now - did you guys solve it? I have a
simple client class that will be a parent in a simple parent-child
relationship. If i add an ArrayList property to the parent class (i
don't even have to decorate it as persistant) i get

EVERE: [1254861190636000] javax.servlet.ServletContext log: Exception
while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type
'org.datanucleus.sco.backed.List' 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.

i've tried java.util.list and java.util.arraylist with same result -
defiitly not a 'org.datanucleus.sco.backed.List'

what's odd is that the RPC call runs in a way and the object is
persisted but without the list field.

Anyway - this seems like something that can't be passed in an RPC call
but i don't see why

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Catagory extends BaseTreeModel implements Serializable {

public Catagory() {}

private static final long serialVersionUID = 1L;
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
private String key;

@Persistent(mappedBy = "catagory")
private List<SubCatagory> subcatagories;
> > GWT 1.7 GAE 1.2.2- Hide quoted text -
>
> - Show quoted text -

Sudeep S

unread,
Oct 6, 2009, 5:06:40 PM10/6/09
to google-we...@googlegroups.com
 Hey Benjamin,
 
 Since u are using Generics ensure that all the classes Service, ServiceAync and ServiceImpl
 use the same signature i.e List<SubCatagory>  .
 
 btw which version of gwt are u using.
 
 Also, you can the temp dir where u can find a rpc.log file with the list of all objects that are serialized.

Lubomir

unread,
Oct 7, 2009, 5:48:33 AM10/7/09
to Google Web Toolkit
Hi, I was experimenting with it a bit as well and it seems to me that
even the most simple Entity bean cannot be passed through RPC call. I
had a simple class:

@Entity
public class Tournament implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private int tournamentId;

@Temporal(value = TemporalType.DATE)
private Date date;
...
and I wasnt able either to pass it from the server to the client or
the other way. Once I removed all the JPA annotation (no other
change!), everything went fine. So I think despite the fact that the
class above is de facto compliant with GWT requirements for via-RPC-
sendable classes (see the docs - serializable, fields serializable,
etc.), it's the JPA annotations and its processing by DataNucleus that
create the problem.
That there's some kind of problem can also be seen in the tutorial for
GWT and appengine: instead of much more natural approach (from certain
point of view) of creating the Stock entity in client code and sending
it through RPC, addStock is called only with String argument and Stock
Entity is constructed on server. Same with getStock: stock list is
fetched from datastore and then parsed and getStock() passes array of
Strings back to client, although it would be nice and convenient to
have Stock entity on client and populate the table by calling getters.
The solution is to use either DTO pattern or a 3rd party library
called Gilead (that does basically the same boring work of cloning
entity, passing it to the client and when it comes back, merging it
with the original)
LZ

Dominik Steiner

unread,
Oct 8, 2009, 7:49:43 PM10/8/09
to Google Web Toolkit
Hi,

I'm using JDO with App Engine and GWT and sending the domain objects
with the JDO tags via RPC is working fine, so not sure if the problem
is JPA?

HTH

Dominik

brancoch

unread,
Oct 8, 2009, 8:22:25 PM10/8/09
to Google Web Toolkit
The problem comes from instrumentation done by the ORM. Most of the
ORM substitute the implementation of the List, Map or Set with their
own implementation since they need to track invocation of method of
the collection. I know that the latest GWT 2.0 code base is putting
code in the RPC framework to support JDO so this is probably why it is
working.
Note that relationship to the one side (for example a Customer entity)
in JPA will likely be instrumented as well.

In my project where we are using Hibernate, I have minimally enhanced
the RPC framework (ServerSerializationStreamWriter.java,
SerializabilityUtil.java) to workaround this issue.

I know other framework are trying to solve this problem but I find my
approach more efficient in term of performance even if it is less
flexible (need to be adapted for other ORM).

I suspect that it should be easy to adapt my approach for DataNucleus.

Let me know if you would like to see the coce?

On Oct 8, 7:49 pm, Dominik Steiner <dominik.j.stei...@googlemail.com>
wrote:

Sam

unread,
Oct 16, 2009, 5:27:40 AM10/16/09
to Google Web Toolkit
@christian

I would like to see your Serialization enhancement/workaround code
please!

Benjamin

unread,
Oct 26, 2009, 12:17:45 PM10/26/09
to Google Web Toolkit
I'm passed these problems now - a couple of things i learned when
creating object and storing in data nucleus for later retrieval over
an RPC call

- Most importantly, if you are returning a complex object (like one
with a list of another type of object) you need to return a copy, not
the object data nucleus returns - return persitenceManager.detachCopy
(object) - the object returned by PM has all sorts of stuff in it
that can't be serialized, the detached copy does not.

Next, if your are creating an object with lists of other object that
are not necessarily parent/child relationships or anything you want to
persist, you need to decorate it with @NotPersistent because app
engine will mark things as persistent for you even if you don't want
it or mark it as persistent. See this note in the doc:

Tip: JDO specifies that fields of certain types are persistent by
default if neither the @Persistent nor @NotPersistent annotations are
specified, and fields of all other types are not persistent by
default. See the DataNucleus documentation for a complete description
of this behavior. Because not all of the App Engine datastore core
value types are persistent by default according to the JDO
specification, we recommend explicitly annotating fields as
@Persistent or @NotPersistent to make it clear.

Cleiton Cavassa

unread,
Nov 8, 2012, 8:10:46 AM11/8/12
to google-we...@googlegroups.com, Google Web Toolkit, mi...@introspect.com

Cool! Benjamin hints worked for me.

Thanks!
Reply all
Reply to author
Forward
0 new messages