GWT RPC is throwing serialization exception when I have object db date value

Caused by: Type ''
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 =Sat Jan 29 00:00:00 PST 2011   



I have implemented serializarion for all of mine Data Transfer Object. But still I am getting this error.

Note: (In gwt RPC you cannot use the Entity objects, You need srializable DTO objects to handle CRUD operations).




The class is a subclass of java.util.Date that ObjectDB uses in order to track changes. It implements but probably this is not sufficient for GWT because Date is a special data type. You may have a similar problem with collection and map fields in your entities.

The solution for date should be using ordinary java.util.Date.

ObjectDB replaces with java.util.Date automatically on ordinary serialization. Following your post - a new build was released (2.0.5_02) in which ObjectDB performs this replacement operation also on detachment (rebuild and enhance your classes again to use this).

So you can use now detached entity objects. Maybe you may even use detached entity objects directly in GWT with no DTO.


ObjectDB Support


I have a similar problem but with java.util.ArrayList instead of java.util.Date.

"The solution for date should be using ordinary java.util.Date."

I am using java.util.LinkedList (and not in my code. But in the database it seems to be stored a a objectdb.* type. Persisting new objects seems to be ok but retrieving data from the database does not work.

I'm using objectdb 2.2.8 and GWT 2.3.0 with embedded jetty in Eclipse. Stack trace is attached.

Any ideas? Is there any way to avoid the usage of those proxy classes?



Hm, interesting. I just found this:

"Most applications are not affected by this, because proxy classes extend the original Java classes and inherit their behavior."

Using Rpc in GWT  is affected. sad I see no way to get those proxy classes on the whitelist of the SerializationPolicy...


Have you tried detaching entities before serializing them using GWT? is replaced with java.util.LinkedList automatically during detachment, so detached entity objects can be serialized using GWT.


ObjectDB Support

Yes, detaching does work for this issue, thank you! But now I have to set fetchtype and cascadetype explicit (which is no problem), otherwise the List will alway be empty after detaching.

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<Transaction> transactions;

That's true. In JPA, objects that have not been loaded before detachment are unavailable after detachment. So you have to load the collection, and using EAGER fetch mode is one way to do that.

ObjectDB Support

I ran in to this problem but didn't want to hassle with detaching.  In my case I have a bunch of data transfer objects that I load my entities in (instead of RPCing my entities) and in the set methods or constructor (depending on how I do it) I just make sure I create a new java.util.Date() object and set the time using the old  SO I have something like


java.util.Date DateDTO = new java.util.Date(ObjectDBDate.getTime());


This works for how I do things in GWT, but might not work for you.