{"id":192,"date":"2006-08-27T12:06:16","date_gmt":"2006-08-27T16:06:16","guid":{"rendered":"http:\/\/www.dr-chuck.com\/wordpress\/?p=192"},"modified":"2011-12-17T12:20:25","modified_gmt":"2011-12-17T16:20:25","slug":"pluto-1-1-bug-sessions-living-across-server-restart","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2006\/08\/pluto-1-1-bug-sessions-living-across-server-restart\/","title":{"rendered":"Pluto 1.1 Bug Session&#8217;s living across server restart"},"content":{"rendered":"<p>There is a bug (I think) in session handling in Pluto 1.1.   Why would Pluto 1.1 keep a session across a Tomcat restart!<br \/>\nI think that this has to do with Tomcat&#8217;s session serialization across startups and Pluto&#8217;s blind dependence on Tomcat session for storing the Pluto session.<br \/>\n..\/work\/Catalina\/localhost\/sakai-portlets\/SESSIONS.ser<br \/>\nIf I am crazy &#8211; just tell me so.<\/p>\n<p><!--more--><br \/>\nI have a portlet &#8211; with these lines at the beginning:<br \/>\npublic void doView(RenderRequest request, RenderResponse response)<br \/>\nthrows PortletException, IOException {<br \/>\nPortletSession pSession = request.getPortletSession(true);<br \/>\nString fred = (String) pSession.getAttribute(&#8220;fred&#8221;);<br \/>\nSystem.out.println(&#8220;Fred = &#8220;+fred);<br \/>\npSession.setAttribute(&#8220;fred&#8221;,&#8221;fred was here&#8221;);<br \/>\nThe &#8220;fred&#8221; attribute is used no where else in the portlet.  Sometimes the portlet puts non-serializable stuff in session.<br \/>\n[DEBUG] PortletEntityImpl &#8211; Loading portlet definition for context: \/sakai-portlets[DEBUG] PortletEntityImpl &#8211; Retrieved cross context: org.apache.catalina.core.ApplicationContextFacade@5e2d6c<br \/>\n[DEBUG] PortletRequestImpl &#8211; Retreiving portlet session (create=true)[DEBUG] PortletRequestImpl &#8211; Creating new portlet session&#8230;<br \/>\nFred = null<br \/>\nRan the portlet in a way that puts a non-serializable thing in session.<br \/>\nShutdown Tomcat &#8211; got the following exception:<br \/>\nWARN: Cannot serialize session attribute javax.portlet.p.\/sakai-portlets.SakaiLaunch?site.list for session 77C3CD8BE5687531A4BA57BC87AFCB5C (2006-08-27 11:53:07,973 main_org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[\/sakai-portlets])<br \/>\njava.io.NotSerializableException: org.sakaiproject.portlets.SakaiLaunch$SakaiSite        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)<br \/>\nat java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1245)        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1069)<br \/>\nat java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)        at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:380)<br \/>\nat java.util.Vector.writeObject(Vector.java:1018)<br \/>\nI start Tomcat back up &#8211; the serialized file does not exist before I run my portlet:<br \/>\nls -l ..\/work\/Catalina\/localhost\/sakai-portlets\/SESSIONS.ser<br \/>\nls: ..\/work\/Catalina\/localhost\/sakai-portlets\/SESSIONS.ser: No such file or directory<br \/>\nWhen my portlet first runs, my session is clean:<br \/>\n[DEBUG] PortletRequestImpl &#8211; Retreiving portlet session (create=true)<br \/>\n[DEBUG] PortletRequestImpl &#8211; Creating new portlet session&#8230;<br \/>\nFred = null<br \/>\nThe serialization file does not exist.<br \/>\nls -l ..\/work\/Catalina\/localhost\/sakai-portlets\/SESSIONS.ser<br \/>\nls: ..\/work\/Catalina\/localhost\/sakai-portlets\/SESSIONS.ser: No such file or directory<br \/>\nRan ran portlet in such a way that the session data *was* all serializable.<br \/>\nShutdown Tomcat &#8211; no exceptions and SESSIONS.ser appears :(<br \/>\nls -l ..\/work\/Catalina\/localhost\/sakai-portlets\/SESSIONS.ser<br \/>\n-rw-r&#8211;r&#8211;   1 csev  csev  2724 Aug 27 11:43 ..\/work\/Catalina\/localhost\/sakai-portlets\/SESSIONS.ser<br \/>\n*** Had the fred string in the file<br \/>\nStart Tomcat back up &#8211; no exceptions &#8211; everything is serializable  &#8211; but the session stuff came back (i.e. the value for fred lasted across server reboots!)<br \/>\n[DEBUG] PortletEntityImpl &#8211; Loading portlet definition for context: \/sakai-portlets<br \/>\n[DEBUG] PortletEntityImpl &#8211; Retrieved cross context: org.apache.catalina.core.ApplicationContextFacade@d55e49<br \/>\n[DEBUG] PortletRequestImpl &#8211; Retreiving portlet session (create=true)<br \/>\n[DEBUG] PortletRequestImpl &#8211; Creating new portlet session&#8230;<br \/>\nFred = fred was here<br \/>\nThe workaround is to simply remove the ..\/work\/Catalina\/localhost\/sakai-portlets\/SESSIONS.ser each time it exists.<br \/>\nAnd even more clever workaround is to put something horrible and non-serializable in the session, each time.<br \/>\nThis seems like a very bad policy &#8211; that portlet session data lives beyond server restart. This looks like it is Tomcat doing the session management and Pluto 1.1 is just using the Tomcat Session to store the data &#8211; but we do need inside portlets to know when we are being run for the first time for a new user to do things like log in and retrieve web services.<br \/>\nIs there something in my portlet.xml to say &#8220;I would like (DUH) a fresh session when the server restarts&#8221; &#8211; or is this unspecified behavior &#8211; i it is unspecified &#8211; the Pluto 1.1 behavior is wrong.<br \/>\nThis is the version I am using<br \/>\ncharles-severances-computer:~\/dev\/pluto-1.1\/pluto-1.1 csev$ svn info<br \/>\nPath: .<br \/>\nRepository Root: http:\/\/svn.apache.org\/repos\/asf<br \/>\nRepository UUID: 13f79535-47bb-0310-9956-ffa450edef68<br \/>\nRevision: 434235<br \/>\nNode Kind: directory<br \/>\nSchedule: normal<br \/>\nLast Changed Author: cdoremus<br \/>\nLast Changed Rev: 434172<br \/>\nLast Changed Date: 2006-08-23 16:54:38 -0400 (Wed, 23 Aug 2006)<br \/>\nProperties Last Updated: 2006-05-11 09:16:39 -0400 (Thu, 11 May 2006)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a bug (I think) in session handling in Pluto 1.1. Why would Pluto 1.1 keep a session across a Tomcat restart! I think that this has to do with Tomcat&#8217;s session serialization across startups and Pluto&#8217;s blind dependence on Tomcat session for storing the Pluto session. ..\/work\/Catalina\/localhost\/sakai-portlets\/SESSIONS.ser If I am crazy &#8211; just [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=192"}],"version-history":[{"count":1,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/192\/revisions"}],"predecessor-version":[{"id":2293,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/192\/revisions\/2293"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}