ICEfaces
  1. ICEfaces
  2. ICE-1271

NotSerializableExceptions on Tomcat startup/shutdown

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.3
    • Fix Version/s: 1.6DR#6, 1.6
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      windows xp

      Description

      When Tomcat is configured to replicate sessions on startup and shutdown it will attempt to serialize anything in the session not marked transient. ICEfaces does not yet support session replication, but should still mark non-serializable classes as transient.

      Some currently identified classes/interfaces needing review:

      com.icesoft.faces.ResponseState
      com.icesoft.faces.webapp.xmlhttp.ResponseState
      com.icesoft.faces.PersistentFacesState
      com.icesoft.faces.sessionAuxiliaryData

        Issue Links

          Activity

          Philip Breau created issue -
          Hide
          Philip Breau added a comment -

          the following changes seem to make all of the exceptions go away. Tomcat tries to serialize anything put in the session of a distributed web app, so there's a problem with putting the UIViewRoot directly into the session as it's not serializable.

          • make the following transient

          BlockingResponseState:
          private transient Object eventLock = new Object();
          protected transient HttpSession session;

          PersistentFacesState:
          transient FacesContext facesContext;

          • create a serializable wrapper for the UIViewRoot:
              • +++ C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\SerializableUIViewRootWrapper.java 2007-02-21 17:01:58.000000000 -0700
                @@ -0,0 +1,22 @@
                +package com.icesoft.faces.context;
                +
                +import java.io.Serializable;
                +import javax.faces.component.UIViewRoot;
                +
                +public class SerializableUIViewRootWrapper implements Serializable

                Unknown macro: {+ + private transient UIViewRoot viewRoot;+ + public UIViewRoot getViewRoot(){ + return viewRoot; + }+ + public void setViewRoot(UIViewRoot viewRoot){ + this.viewRoot = viewRoot; + }+ + public SerializableUIViewRootWrapper(UIViewRoot root){ + this.viewRoot = root; + }++}

          — C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\application\D2DViewHandler.java 2007-01-24 18:16:26.000000000 -0700
          +++ C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\application\D2DViewHandler.java 2007-02-22 09:46:46.000000000 -0700
          @@ -33,12 +33,13 @@

          package com.icesoft.faces.application;

          import com.icesoft.faces.context.BridgeExternalContext;
          import com.icesoft.faces.context.BridgeFacesContext;
          import com.icesoft.faces.context.DOMResponseWriter;
          +import com.icesoft.faces.context.SerializableUIViewRootWrapper;
          import com.icesoft.faces.env.CommonEnvironmentResponse;
          import com.icesoft.faces.webapp.parser.JspPageToDocument;
          import com.icesoft.faces.webapp.parser.Parser;
          import com.icesoft.faces.webapp.xmlhttp.BlockingServlet;
          import com.icesoft.faces.webapp.xmlhttp.PersistentFacesCommonlet;
          import com.icesoft.util.SeamUtilities;
          @@ -183,28 +184,28 @@
          if (delegateView(viewId))

          { return delegate.createView(context, viewId); }

          UIViewRoot root = new UIViewRoot();
          root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
          -
          + SerializableUIViewRootWrapper viewRootWrapper = new SerializableUIViewRootWrapper(root);
          Map contextServletTable =
          D2DViewHandler.getContextServletTable(context);
          if (null == viewId)

          { root.setViewId("default"); context.setViewRoot(root); contextServletTable - .put(DOMResponseWriter.RESPONSE_VIEWROOT, root); + .put(DOMResponseWriter.RESPONSE_VIEWROOT, viewRootWrapper); Locale locale = calculateLocale(context); root.setLocale(locale); return root; }

          root.setViewId(viewId);
          context.setViewRoot(root);

          • contextServletTable.put(DOMResponseWriter.RESPONSE_VIEWROOT, root);
            + contextServletTable.put(DOMResponseWriter.RESPONSE_VIEWROOT, viewRootWrapper);

          return root;
          // return restoreView(context, viewId);
          }

          /**
          @@ -276,14 +277,17 @@
          contextServletTable.put(DOMResponseWriter.RESPONSE_CONTEXTS_TABLE,
          domResponseContexts);
          }

          UIViewRoot root = null;

          • root = (UIViewRoot) contextServletTable
          • .get(DOMResponseWriter.RESPONSE_VIEWROOT);
            + SerializableUIViewRootWrapper viewRootWrapper = ((SerializableUIViewRootWrapper) contextServletTable
            + .get(DOMResponseWriter.RESPONSE_VIEWROOT));
            + if( viewRootWrapper != null ) { + root = viewRootWrapper.getViewRoot(); + }

          if ((null != root) && (null != viewId)) {
          if (D2DViewHandler.mungeViewId(viewId)
          .equals(D2DViewHandler.mungeViewId(root.getViewId())))

          { // return root; }

          — C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\BridgeFacesContext.java 2006-10-25 13:11:10.000000000 -0700
          +++ C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\BridgeFacesContext.java 2007-02-22 10:16:27.000000000 -0700
          @@ -212,39 +212,46 @@

          public void setResponseWriter(ResponseWriter responseWriter)

          { this.responseWriter = responseWriter; }
          • private UIViewRoot viewRoot;
            + private transient SerializableUIViewRootWrapper viewRootWrapper;

          public UIViewRoot getViewRoot() {

          • if (null == viewRoot) {
            + if (null == viewRootWrapper) {
            Map contextServletTable = getContextServletTable();
            if (null != contextServletTable) { - viewRoot = (UIViewRoot) contextServletTable + viewRootWrapper = (SerializableUIViewRootWrapper) contextServletTable .get(DOMResponseWriter.RESPONSE_VIEWROOT); }
          • }
            -
          • return (this.viewRoot);
            + else { + + }

            + }
            + if( viewRootWrapper == null )
            + viewRootWrapper = new SerializableUIViewRootWrapper(null);
            + return viewRootWrapper.getViewRoot();
            }

          public void setViewRoot(UIViewRoot viewRoot) {

          • //pointing this FacesContext to the new view
            +
            + this.viewRootWrapper = new SerializableUIViewRootWrapper(viewRoot);
            +
            + //pointing this FacesContext to the new view
            Map contextServletTable = getContextServletTable();
            if (null != contextServletTable)
            Unknown macro: { if (viewRoot != null) { - contextServletTable - .put(DOMResponseWriter.RESPONSE_VIEWROOT, viewRoot); + contextServletTable + .put(DOMResponseWriter.RESPONSE_VIEWROOT, viewRootWrapper); } else { contextServletTable.remove(DOMResponseWriter.RESPONSE_VIEWROOT); } }

            responseWriter = null;

          • this.viewRoot = viewRoot;
            +
            }

          private static final Log log = LogFactory.getLog(BridgeFacesContext.class);
          String iceFacesId;

          public String getIceFacesId()

          { --- C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\DOMResponseWriter.java 2007-01-15 15:08:20.000000000 -0700 +++ C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\DOMResponseWriter.java 2007-02-22 09:51:18.000000000 -0700 @@ -166,13 +166,13 @@ domResponseContexts = new HashMap(); contextServletTable.put(DOMResponseWriter.RESPONSE_CONTEXTS_TABLE, domResponseContexts); }

          // viewroot, application
          contextServletTable.put(DOMResponseWriter.RESPONSE_VIEWROOT,

          • context.getViewRoot());
            + new SerializableUIViewRootWrapper(context.getViewRoot()));
            cursor = document = DOCUMENT_BUILDER.newDocument();
            contextServletTable.put(DOMResponseWriter.RESPONSE_DOM, document);
            boolean streamWritingParam = "true".equalsIgnoreCase(
            context.getExternalContext().getInitParameter(
            DOMResponseWriter.STREAM_WRITING));
            DOMResponseWriter.isStreamWritingFlag =
          Show
          Philip Breau added a comment - the following changes seem to make all of the exceptions go away. Tomcat tries to serialize anything put in the session of a distributed web app, so there's a problem with putting the UIViewRoot directly into the session as it's not serializable. make the following transient BlockingResponseState: private transient Object eventLock = new Object(); protected transient HttpSession session; PersistentFacesState: transient FacesContext facesContext; create a serializable wrapper for the UIViewRoot: +++ C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\SerializableUIViewRootWrapper.java 2007-02-21 17:01:58.000000000 -0700 @@ -0,0 +1,22 @@ +package com.icesoft.faces.context; + +import java.io.Serializable; +import javax.faces.component.UIViewRoot; + +public class SerializableUIViewRootWrapper implements Serializable Unknown macro: {+ + private transient UIViewRoot viewRoot;+ + public UIViewRoot getViewRoot(){ + return viewRoot; + }+ + public void setViewRoot(UIViewRoot viewRoot){ + this.viewRoot = viewRoot; + }+ + public SerializableUIViewRootWrapper(UIViewRoot root){ + this.viewRoot = root; + }++} — C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\application\D2DViewHandler.java 2007-01-24 18:16:26.000000000 -0700 +++ C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\application\D2DViewHandler.java 2007-02-22 09:46:46.000000000 -0700 @@ -33,12 +33,13 @@ package com.icesoft.faces.application; import com.icesoft.faces.context.BridgeExternalContext; import com.icesoft.faces.context.BridgeFacesContext; import com.icesoft.faces.context.DOMResponseWriter; +import com.icesoft.faces.context.SerializableUIViewRootWrapper; import com.icesoft.faces.env.CommonEnvironmentResponse; import com.icesoft.faces.webapp.parser.JspPageToDocument; import com.icesoft.faces.webapp.parser.Parser; import com.icesoft.faces.webapp.xmlhttp.BlockingServlet; import com.icesoft.faces.webapp.xmlhttp.PersistentFacesCommonlet; import com.icesoft.util.SeamUtilities; @@ -183,28 +184,28 @@ if (delegateView(viewId)) { return delegate.createView(context, viewId); } UIViewRoot root = new UIViewRoot(); root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT); - + SerializableUIViewRootWrapper viewRootWrapper = new SerializableUIViewRootWrapper(root); Map contextServletTable = D2DViewHandler.getContextServletTable(context); if (null == viewId) { root.setViewId("default"); context.setViewRoot(root); contextServletTable - .put(DOMResponseWriter.RESPONSE_VIEWROOT, root); + .put(DOMResponseWriter.RESPONSE_VIEWROOT, viewRootWrapper); Locale locale = calculateLocale(context); root.setLocale(locale); return root; } root.setViewId(viewId); context.setViewRoot(root); contextServletTable.put(DOMResponseWriter.RESPONSE_VIEWROOT, root); + contextServletTable.put(DOMResponseWriter.RESPONSE_VIEWROOT, viewRootWrapper); return root; // return restoreView(context, viewId); } /** @@ -276,14 +277,17 @@ contextServletTable.put(DOMResponseWriter.RESPONSE_CONTEXTS_TABLE, domResponseContexts); } UIViewRoot root = null; root = (UIViewRoot) contextServletTable .get(DOMResponseWriter.RESPONSE_VIEWROOT); + SerializableUIViewRootWrapper viewRootWrapper = ((SerializableUIViewRootWrapper) contextServletTable + .get(DOMResponseWriter.RESPONSE_VIEWROOT)); + if( viewRootWrapper != null ) { + root = viewRootWrapper.getViewRoot(); + } if ((null != root) && (null != viewId)) { if (D2DViewHandler.mungeViewId(viewId) .equals(D2DViewHandler.mungeViewId(root.getViewId()))) { // return root; } — C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\BridgeFacesContext.java 2006-10-25 13:11:10.000000000 -0700 +++ C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\BridgeFacesContext.java 2007-02-22 10:16:27.000000000 -0700 @@ -212,39 +212,46 @@ public void setResponseWriter(ResponseWriter responseWriter) { this.responseWriter = responseWriter; } private UIViewRoot viewRoot; + private transient SerializableUIViewRootWrapper viewRootWrapper; public UIViewRoot getViewRoot() { if (null == viewRoot) { + if (null == viewRootWrapper) { Map contextServletTable = getContextServletTable(); if (null != contextServletTable) { - viewRoot = (UIViewRoot) contextServletTable + viewRootWrapper = (SerializableUIViewRootWrapper) contextServletTable .get(DOMResponseWriter.RESPONSE_VIEWROOT); } } - return (this.viewRoot); + else { + + } + } + if( viewRootWrapper == null ) + viewRootWrapper = new SerializableUIViewRootWrapper(null); + return viewRootWrapper.getViewRoot(); } public void setViewRoot(UIViewRoot viewRoot) { //pointing this FacesContext to the new view + + this.viewRootWrapper = new SerializableUIViewRootWrapper(viewRoot); + + //pointing this FacesContext to the new view Map contextServletTable = getContextServletTable(); if (null != contextServletTable) Unknown macro: { if (viewRoot != null) { - contextServletTable - .put(DOMResponseWriter.RESPONSE_VIEWROOT, viewRoot); + contextServletTable + .put(DOMResponseWriter.RESPONSE_VIEWROOT, viewRootWrapper); } else { contextServletTable.remove(DOMResponseWriter.RESPONSE_VIEWROOT); } } responseWriter = null; this.viewRoot = viewRoot; + } private static final Log log = LogFactory.getLog(BridgeFacesContext.class); String iceFacesId; public String getIceFacesId() { --- C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\DOMResponseWriter.java 2007-01-15 15:08:20.000000000 -0700 +++ C:\work\frameworks\ICEfaces-1.5.3-src\icefaces\core\src\com\icesoft\faces\context\DOMResponseWriter.java 2007-02-22 09:51:18.000000000 -0700 @@ -166,13 +166,13 @@ domResponseContexts = new HashMap(); contextServletTable.put(DOMResponseWriter.RESPONSE_CONTEXTS_TABLE, domResponseContexts); } // viewroot, application contextServletTable.put(DOMResponseWriter.RESPONSE_VIEWROOT, context.getViewRoot()); + new SerializableUIViewRootWrapper(context.getViewRoot())); cursor = document = DOCUMENT_BUILDER.newDocument(); contextServletTable.put(DOMResponseWriter.RESPONSE_DOM, document); boolean streamWritingParam = "true".equalsIgnoreCase( context.getExternalContext().getInitParameter( DOMResponseWriter.STREAM_WRITING)); DOMResponseWriter.isStreamWritingFlag =
          Philip Breau made changes -
          Field Original Value New Value
          Environment windows xp
          Ken Fyten made changes -
          Fix Version/s 1.6DR#4 [ 10060 ]
          Fix Version/s 1.6 [ 10031 ]
          Assignee Priority P2
          Ken Fyten made changes -
          Fix Version/s 1.6 [ 10031 ]
          Fix Version/s 1.6DR#4 [ 10060 ]
          Hide
          Ken Fyten added a comment -

          Bridge use of Session scope vars should be marked "transient".

          Show
          Ken Fyten added a comment - Bridge use of Session scope vars should be marked "transient".
          Ken Fyten made changes -
          Assignee Ted Goddard [ ted.goddard ] Mircea Toma [ mircea.toma ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #14013 Tue May 29 17:02:26 MDT 2007 mircea.toma Wrap values to avoid Tomcat serialization warnings -- ICE-1271, ICE-1068.
          Files Changed
          Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/servlet/ServletSessionMap.java
          Hide
          Mircea Toma added a comment -

          Fixed by wrapping sessions attribute values to avoid Tomcat serialization warnings.

          Show
          Mircea Toma added a comment - Fixed by wrapping sessions attribute values to avoid Tomcat serialization warnings.
          Mircea Toma made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Mircea Toma made changes -
          Link This issue duplicates ICE-1068 [ ICE-1068 ]
          Hide
          Ted Goddard added a comment -

          Fix reportedly breaks Seam. Assigning to Judy to verify against a test case of Mircea's choice (i.e. booking or seam-gen).

          Show
          Ted Goddard added a comment - Fix reportedly breaks Seam. Assigning to Judy to verify against a test case of Mircea's choice (i.e. booking or seam-gen).
          Ted Goddard made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Assignee Priority P2 P1
          Assignee Mircea Toma [ mircea.toma ] Judy Guglielmin [ judy.guglielmin ]
          Mircea Toma made changes -
          Link This issue is duplicated by ICE-1729 [ ICE-1729 ]
          Ken Fyten made changes -
          Assignee Judy Guglielmin [ judy.guglielmin ] Mircea Toma [ mircea.toma ]
          Hide
          Mircea Toma added a comment -

          See ICE-1729.

          Show
          Mircea Toma added a comment - See ICE-1729 .
          Mircea Toma made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Ken Fyten added a comment -

          Issue is resolved with regard to ICEfaces framework generated exceptions by marking appropriate variables as transient.

          Show
          Ken Fyten added a comment - Issue is resolved with regard to ICEfaces framework generated exceptions by marking appropriate variables as transient.
          Ken Fyten made changes -
          Issue Type Bug [ 1 ] Improvement [ 4 ]
          Ken Fyten made changes -
          Fix Version/s 1.6DR#6 [ 10090 ]
          Fix Version/s 1.6 [ 10031 ]
          Ken Fyten made changes -
          Fix Version/s 1.6 [ 10031 ]
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Assignee Priority P1
          Assignee Mircea Toma [ mircea.toma ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Philip Breau
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: