Serialization issues

67 views
Skip to first unread message

Nialls Chavez

unread,
Mar 24, 2012, 6:10:36 PM3/24/12
to google-we...@googlegroups.com
Hello, 

    I am working on some code that will do serialization on a canvas(SmartGWT canvas)  so that it could be saved to the server in a database, I found some example code that I am using on how to do serialization in GWT but i keep getting the following error: 
[ERROR] [web_final] - Line 22: No source code is available for type com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter; did you forget to inherit a required module?
[ERROR] [web_final] - Line 46: No source code is available for type com.google.gwt.user.server.rpc.SerializationPolicy; did you forget to inherit a required module?

and here is the code that is generating it: 

import com.google.gwt.core.client.GWT;

import com.google.gwt.user.client.rpc.SerializationException;

import com.google.gwt.user.client.rpc.SerializationStreamFactory;

import com.google.gwt.user.server.rpc.SerializationPolicy;

import com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter;

import com.smartgwt.client.widgets.Canvas;

public class CanvasSerialize{

    public CanvasSerialize() {}    

    public String doSerialize(Canvas canvasIn){

        Class<?> responseClass = canvasIn.getClass();

        // make a serialization policy of my own to use, normally deteremined by rpc request

        ServerSerializationStreamWriter stream = new ServerSerializationStreamWriter(new SerializePolicy());

        stream.prepareToWrite();

        if (responseClass != void.class) {

        try {

                stream.serializeValue(canvasIn, responseClass);

                } catch (SerializationException e) {e.printStackTrace();}

        }

        String bufferStr = stream.toString();

        return bufferStr;

    }

    public Canvas deSerialize(String buffer){

     SerializationStreamFactory ssf = GWT.create( Canvas.class);

        Canvas decodedObject = null;

try {

decodedObject = (Canvas)ssf.createStreamReader( buffer ).readObject();

} catch (SerializationException e) { e.printStackTrace();}

        return decodedObject;

    }

    private class SerializePolicy  extends SerializationPolicy {

      @Override

        public boolean shouldDeserializeFields(Class<?> clazz) {

                return false;

        }

        @Override

        public boolean shouldSerializeFields(Class<?> clazz) {

                return false;

        }

        @Override

        public void validateDeserialize(Class<?> clazz)

                        throws SerializationException {

        }

        @Override

        public void validateSerialize(Class<?> clazz) throws SerializationException {

        }

    }

}


I have this file inside the server package, but i am calling it client side, is that the  issue? any help would be greatly appreciated.


Thanks!

Joseph Lust

unread,
Mar 30, 2012, 1:26:42 PM3/30/12
to google-we...@googlegroups.com
You either are missing a jar or forget to inherit a required module.

Sincerely,
Joseph
Reply all
Reply to author
Forward
0 new messages