1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    118
    Vote Rating
    0
    Kutu is on a distinguished road

      0  

    Default Serialization Policy issue

    Serialization Policy issue


    I am currently having issue with the Serialization Policy from GWT:

    This is the class in which GWT dislike: ClientServiceDescription

    Code:
    /** Simple container class which contains descriptions of running services. */
    public class ClientServiceDescription implements Serializable {
    
        private String status;
        private String serviceId;
    
        /**
         * Get the status.
         * 
         * @return Return the status.
         */
        public String getStatus() {
            return this.status;
        }
    
        /**
         * Set the status.
         * 
         * @param status The status to set.
         */
        public void setStatus(final String status) {
            this.status = status;
        }
    
        /**
         * Get the serviceId.
         * 
         * @return Return the serviceId.
         */
        public String getServiceId() {
            return this.serviceId;
        }
    
        /**
         * Set the serviceId.
         * 
         * @param serviceId The serviceId to set.
         */
        public void setServiceId(final String serviceId) {
            this.serviceId = serviceId;
        }
    
        /**
         * To String method.
         * 
         * @return str
         */
        public String toString() {
            return "[Service: " + this.getServiceId() + " Status:" + this.getStatus() + "]";
        }
    }

    This is another class that holds a list of ClientServiceDescription:

    Code:
    /**
     * <p>
     * Client representation of the status of an EC2 node.
     * </p>
     * 
     * @author edwin.nathaniel
     * @version $Revision:693 $
     */
    public class ClientNodeStatus extends BaseModel implements Serializable {
    
        private static final int FNGROUP = 0;
        private static final int FIP = 1;
        private static final int FID = 2;
        private static final int FIMG = 3;
        private static final int FIMGSZ = 4;
        private static final int FLAUNCH = 5;
        private static final int FSTATE = 6;
        private static final int FSERVICES = 7;
        private static final int FPUBDNS = 8;
    
        private String[] properties = {
                "nodeGroup", "ip", "instanceId", "image", "imageSize", "launchTime", "state", "services", "publicDns"
        };
    
        /**
         * Get the NodeGroup this Node belongs to.
         * 
         * @return cng
         */
        public ClientNodeGroup getNodeGroup() {
            return (ClientNodeGroup) this.get(this.properties[FNGROUP]);
        }
    
        /**
         * Set the NodeGroup this Node belongs to.
         * 
         * @param cng
         */
        public void setNodeGroup(final ClientNodeGroup cng) {
            this.set(this.properties[FNGROUP], cng);
        }
    
        /**
         * Get the iP.
         * 
         * @return Return the iP.
         */
        public String getIp() {
            return (String) this.get(this.properties[FIP]);
        }
    
        /**
         * Set the iP.
         * 
         * @param ip The iP to set.
         */
        public void setIp(final String ip) {
            this.set(this.properties[FIP], ip);
        }
    
        /**
         * Get the instance id.
         * 
         * @return Return the id.
         */
        public String getInstanceId() {
            return (String) this.get(this.properties[FID]);
        }
    
        /**
         * Set the id.
         * 
         * @param id The id to set.
         */
        public void setInstanceId(final String id) {
            this.set(this.properties[FID], id);
        }
    
        /**
         * Get the image.
         * 
         * @return Return the image.
         */
        public String getImage() {
            return (String) this.get(this.properties[FIMG]);
        }
    
        /**
         * Set the image.
         * 
         * @param image The image to set.
         */
        public void setImage(final String image) {
            this.set(this.properties[FIMG], image);
        }
    
        /**
         * Get the imageSize.
         * 
         * @return Return the imageSize.
         */
        public String getImageSize() {
            return (String) this.get(this.properties[FIMGSZ]);
        }
    
        /**
         * Set the imageSize.
         * 
         * @param imageSize The imageSize to set.
         */
        public void setImageSize(final String imageSize) {
            this.set(this.properties[FIMGSZ], imageSize);
        }
    
        /**
         * Get the launchTime.
         * 
         * @return Return the launchTime.
         */
        public String getLaunchTime() {
            return (String) this.get(this.properties[FLAUNCH]);
        }
    
        /**
         * Set the launchTime.
         * 
         * @param launchTime The launchTime to set.
         */
        public void setLaunchTime(final String launchTime) {
            this.set(this.properties[FLAUNCH], launchTime);
        }
    
        /**
         * Get the state.
         * 
         * @return Return the state.
         */
        public String getState() {
            return (String) this.get(this.properties[FSTATE]);
        }
    
        /**
         * Set the state.
         * 
         * @param state The state to set.
         */
        public void setState(final String state) {
            this.set(this.properties[FSTATE], state);
        }
    
        /**
         * Get the services.
         * 
         * @return Return the services.
         */
        public List<ClientServiceDescription> getServices() {
            return (List<ClientServiceDescription>) this.get(this.properties[FSERVICES]);
        }
    
        /**
         * Set the services.
         * 
         * @param services The services to set.
         */
        public void setServices(final List<ClientServiceDescription> services) {
            this.set(this.properties[FSERVICES], services);
        }
    
        /**
         * Get the public DNS value.
         * 
         * @return publicDns
         */
        public String getPublicDns() {
            return (String) this.get(this.properties[FPUBDNS]);
        }
    
        /**
         * Set the public DNS value.
         * 
         * @param pubDns
         */
        public void setPublicDns(final String pubDns) {
            this.set(this.properties[FPUBDNS], pubDns);
        }
    
    }
    As far as I understand, GWT is happily to accept user-defined Java class.

  2. #2
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    2
    gslender is on a distinguished road

      0  

    Default


    I think you may need to include

    Code:
    private static final long serialVersionUID = [some long unique number]L;

  3. #3
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    59
    Vote Rating
    0
    LukasP is on a distinguished road

      0  

    Default


    What exact Exception do you get?
    I had a problem with the 1.5 RC1 release, too which I hope is going to be fixed soon but there is a workaround...

  4. #4
    Ext User
    Join Date
    May 2008
    Posts
    97
    Vote Rating
    0
    jraue is on a distinguished road

      0  

    Default


    I had a Serialization Policy issue yesterday (Object could not be deserialized because not included in policy or similar). Anyway, the problem disappeared after deleting the .gwt-cache folder. Maybe this helps for you as well?

  5. #5
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    59
    Vote Rating
    0
    LukasP is on a distinguished road

      0  

    Default


    No it was concerning the new GWT 1.5 RC1 - there was a bug on Serializing Vectors e.g. but some others, too.
    Anyways my bug has been fixed

    If anyone else encounters SerializationException you should have a look at the gwt google group...

  6. #6
    Ext User
    Join Date
    May 2008
    Posts
    105
    Vote Rating
    0
    Grandiosa is on a distinguished road

      0  

    Default


    According to this your first class should be ok although it doesn't have a zero-arg constructor.

    I had similar problems earlier with serialization of BaseModel classes having collections of other objects. After wasting hours on trying to figure out what was wrong I changed all my BaseModel classes to BasetTreeModel instead, and it worked.

    If you look at the Explorer sample and its model classes they extend BaseTreeModel as well, although they don't utilize the children/parent semantics. I suspect Darrel did this as a workaround to similar RPC problems as you're referring to.