2
votes

A developer declared this in a class which implements Serializable interface.

XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://employer.webservicedto.dto.com", name = employerRequestDTO")
public class EmployerRequestDTO implements Serializable{

 private static final long serialVersionUID = -3956940714175091216L;
 // all private instance variables with getters & setters

}

and the stacktrace says -

decodeRequestData - Exception in decodeReqData() : java.io.InvalidClassException: EmployerRequestDTO; local class incompatible: stream classdesc serialVersionUID = -3551130751187195282, local class serialVersionUID = -3956940714175091216

/**
     * This method de-serializes user's request-data to return respective DTOs
     */
    public static Object decodeRequestData(String requestData, String userType){
        Object userRequestDTO = null;
        try{    
            byte[] b = Base64.decode(requestData);
            ByteArrayInputStream bi = new ByteArrayInputStream(b);
            ObjectInputStream si = new ObjectInputStream(bi);
1
'@XmlType(namespace = "employer.webservicedto.dto.com", name = employerRequestDTO)' - Crammeur

1 Answers

2
votes

It looks like the class was serialized with the serialVersionUID value set to -3551130751187195282 then the class was updated in source and serialVersionUID was set to -3956940714175091216. So now the source of the class is not compatible with the version that was serialized. You can try setting serialVersionUID back to -3551130751187195282 - but i would be careful with that. Try to find out why this value was changed - maybe there where other changes in the class source which makes it not possible to use with previously serialized versions.