Bug 59054 - CrawlerSessionManagerValve is not serializable, and throws exception when passing itself as sessionAttribute
Summary: CrawlerSessionManagerValve is not serializable, and throws exception when pas...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Connectors (show other bugs)
Version: 7.0.64
Hardware: All All
: P2 critical (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-23 14:48 UTC by Kuba
Modified: 2016-02-25 08:15 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kuba 2016-02-23 14:48:28 UTC
During first request to the application when user agent matches crawler pattern the execution reaches the point where it tries to store itself in sessionAttribute (s1.setAttribute(this.getClass().getName(), this)). Since CrawlerSessionManagerValve does not implement Serializable it throws exception:

java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute org.apache.catalina.valves.CrawlerSessionManagerValve
	at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1465)
	at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1426)
	at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:154)
	at org.apache.catalina.valves.CrawlerSessionManagerValve.invoke(CrawlerSessionManagerValve.java:190)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
	at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)



I was able to fix this bug by modyfing source code to implement Serializable interface.
Comment 1 Mark Thomas 2016-02-23 15:14:41 UTC
You should only see this error in a distributed environment.

The CrawlerSessionManagementValve isn't intended to be distributed so I have added to the list of attributes that are excluded from this process. This fix has been applied to 9.0.x (for 9.0.0.M4 onwards), 8.0.x (for 8.0.33 onwards) and 7.0.x for 7.0.69 onwards.
Comment 2 Kuba 2016-02-25 08:12:08 UTC
Thanks for reply. Can you explain how  distributed enviroment can influence this behaviour.
The class is not serializable so any StandardSession.setAttribute() call with it as a parameter will end up throwing exception, won't it? Apart from that I am not using distributed enviroment.
Comment 3 Remy Maucherat 2016-02-25 08:15:52 UTC
If you have further questions, please use the user list, bugzilla is not a support forum. Thanks.