Your Long object was probably not found from examining your remote interface. You can even put "dummy" methods or parameters on your remote interfaces (or classes directly referenced by them) just so the compiler picks up the fact that you need to be able to serialize them.

Also, you should avoid long or Long if possible because they are emulated on GWT (because there is no native Javascript long) and very slow. Use int instead where ever you can.

On 26 May 2010, at 01:57, Iván Navarro wrote:

hi,
as I read in the Docs it must be no problem serializing Long values,
but anyway I have one.


com.google.gwt.user.client.rpc.SerializationException: Type
'java.lang.Long' 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 = 18
        at
com .google .gwt .user .server .rpc .impl .ServerSerializationStreamWriter .serialize(ServerSerializationStreamWriter.java:
610)
        at
com .google .gwt .user .client .rpc .impl .AbstractSerializationStreamWriter .writeObject(AbstractSerializationStreamWriter.java:
129)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter
$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)

This is is the servlet where I have the problem:

public class UserGServiceImpl extends RemoteServiceServlet implements
UserGService{

        private static final long serialVersionUID = 7846225142061604894L;

        public TrackerUser getCurrentUser(String requestUri) throws
IllegalArgumentException {
                UserService userService = UserServiceFactory.getUserService();
       User user = userService.getCurrentUser();
       TrackerUser theTrackerUser = new TrackerUser();

       if (user != null){
        theTrackerUser.setLoggedIn(true);

theTrackerUser.setLogoutUrl(userService.createLogoutURL(requestUri));
        theTrackerUser.setMail(user.getEmail());
        theTrackerUser.setNickName(user.getNickname());
        DBTrackerUser theDBUser =
PrettyStorage.getTrackerUser(user.getEmail());
        if (theDBUser == null){
                Long userId =
PrettyStorage.insertTrackerUser(user.getEmail(), user.getNickname());
                theTrackerUser.setUserId(userId.longValue());
        }
        else{
                theTrackerUser.setUserId(theDBUser.getId());
        }
       }
       else{
        theTrackerUser.setLoggedIn(false);

theTrackerUser.setLoginUrl(userService.createLoginURL(requestUri));
       }

       return theTrackerUser;
        }

}

And part of the TrackerUser class:

public class TrackerUser implements IsSerializable{

        private boolean loggedIn = false;
        private String loginUrl;
        private String logoutUrl;
        private Long userId;
        private String mail;
        private String nickName;

The most strange thing is that the problem only appears when the
DBUser == null and I have to insert a new one in the database.
For the moment I solve the issue changing type Long by long but I
still have the doubt of why it doesn't work.

Thanks,

Iván

--
You received this message because you are subscribed to the Google Groups "Google App Engine for Java" 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-appengine-java?hl=en .


--
You received this message because you are subscribed to the Google Groups "Google 
App Engine for Java" 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-appengine-java?hl=en.

Reply via email to