Today, the team members encountered a very strange problem. When Tomcat 6 was started and closed, the following exception was thrown: Cannot serialize session attribute XXX. I am very puzzled. I checked it on the Apache official website and found that Tomcat will try to serialize session resources. if the related objects in sessions do not implement the serializable interface, the Cannot serialize session attribute XXX for exception will occur. Because a serializable interface is implemented for a class, Tomcat is started, and the serializable interface is canceled, an error is returned when Tomcat is restarted. The original article is as follows:
Because when you shutdown tomcat, it tries to serial all objects
The session scope.
Class you are referring
'Org. Apache. commons. fileupload. deferredfileoutputstream 'does not
Implement 'java. Io. serializable' and therefore Tomcat throws this
Exception when trying to serialize it.
Whilst I don't know what the class
'Org. Apache. Catalina. session. standardmanager' does, presumably is
Performs a check to see if an object stored within the session is
Serializable before trying
Write it disk, or it might remove non-serializable object from
Session scope on shutdown.
If you do not want to see this exception, you do not want to save the session. then you can deploy the file in the project description file (such. test. XML,) (instead of just exploding the war) <context> tags plus:
<Manager className="org.apache.catalina.session.PersistentManager"saveOnRestart="false"/>
In this way, Tomcat will not save session resources when it is disabled. You can also specify the above value in server. xml. This is also used by all programs.