0

I'm using java, eclipse, gwt, rpc, app engine, datastore.

I have a serializable class (Usuario) and I placed it on the shared package to be able to use it on the client and server packages, and it works fine, the only problem is that java.util.Date fields are admitted only if I place the class on the server package. If I place it on the shared package, it shows this run-time error:

SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call com.google.gwt.user.client.rpc.SerializationException: Type 'org.datanucleus.store.types.sco.simple.Date' 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 = Mon Feb 16 18:56:56 COT 2015

Take a look at the class

package com.mydomain.mydomain.shared;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Usuario implements Serializable{
    private static final long serialVersionUID = 1L;
    @PrimaryKey
    @Persistent
    private String email;
    @Persistent
    private String customNickname;
    @Persistent
    private Date creationDate;

public Usuario() {
  this.creationDate = new Date(0);
}...

If I move the class to the server package I cannot use this class in the client because it shows this compilation error:

[ERROR] Errors in 'file:/C:/Users/Me/workspace/Mydomain/src/com/mydomain/mydomain/client/Mydomain.java'
[ERROR] Line 253: No source code is available for type com.mydomain.mydomain.server.Usuario; did you forget to inherit a required module?
[ERROR] Unable to find type 'com.mydomain.mydomain.client.Mydomain'

thanks

  • 2
    Seems your error is not about `java.util.Date` but about `org.datanucleus.store.types.sco.simple.Date` – peter.petrov Feb 21 '15 at 23:58
  • 1
    @peter.petrov isn't it annoying when people don't read error messages and then ask how to fix them? – user253751 Feb 21 '15 at 23:59
  • More generally, see https://stackoverflow.com/questions/1056012/sending-persisted-jdo-instances-over-gwt-rpc for info on how to deal with GWT serialization and JDO annotations. You should try to keep your persistence capable classes server-side though. – Adam Feb 23 '15 at 03:05

0 Answers0