2

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);
James Z
  • 12,209
  • 10
  • 24
  • 44
Farhan stands with Palestine
  • 13,890
  • 13
  • 58
  • 105

1 Answers1

2

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.

kaos
  • 1,598
  • 11
  • 15
  • Thanks, this was my issue. I had assumed that re-serializing with a "new" singleton (which was my error recovery) would have fixed it, but I had to explicitly delete the existing file. – Oded Jan 23 '21 at 00:49