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

          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 =
          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".
          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.
          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).
          Hide
          Mircea Toma added a comment -

          See ICE-1729.

          Show
          Mircea Toma added a comment - See ICE-1729 .
          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.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: