Tomcat throws a Cannot serialize session attribute exception.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.