Search code examples
javaspringserializationweblogicapache-commons

InvalidClassException error while deserializing session data


Here is the calling code:

Object attribute = session.getAttribute(name, scope);

and this throws the following eror:

Could not deserialize session data.
java.io.InvalidClassException: org.apache.commons.lang.time.FastDateFormat; local class  incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = -7186497712641044641

The environment is Weblogic. The Web application is a spring portlet. I'm trying to understand how to fix this issue.


Solution

  • Had to add the commons-lang to the "preferred application packages" section of weblogic.xml to get this fixed.

    <container-descriptor>
        <prefer-application-packages>
            <package-name>org.apache.commons.lang.*</package-name>
        </prefer-application-packages>
        <optimistic-serialization>true</optimistic-serialization>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>