I updated my User class, and now whenever someone that had the old version of the User class stored in their session scope accesses my site, I get an InvalidClassException.
javax.servlet.ServletException: java.lang.RuntimeException:
java.io.InvalidClassException: User; local class incompatible:
stream classdesc serialVersionUID = 4949038118012519093,
local class serialVersionUID = -971500502189813151
How do I stop this error from happening for those users? I could probably invalidate everyone’s sessions every time I want to update a class that gets stored in session scope, but is there a better way, so that my user’s don’t have to login again?
You can add
to your class definition. New class should have the same serializable fields in the same order of course.