title: NotSerializableException when shutting down glassfish
body: <p>I get an <code>NotSerializableException</code> when shutting down Glassfish (3.1), due to an <code>HtmlSelectOneMenu</code>. I use <code>HtmlSelectOneMenu</code> in other controller beans, but they are not bound to the backing bean as this one. This happens only if there are sessions active on the server of course.</p>
  
  <p>How can I avoid exception when starting/stopping Glassfish for the bounded JSF component ?</p>
  
  <p>Controller Class</p>
  
  <pre><code>@ManagedBean
  @SessionScoped
  ...
  
  public class ActivityController implements Serializable {
      ..
      private DataModel&lt;MyObjcet&gt; items = null;
      private HtmlSelectOneMenu myMenu;
      ...
  </code></pre>
  
  <p>Exception</p>
  
  <pre><code>INFO: PWC2785: Cannot serialize session attribute activityController for session a4591e053e65effc743dade67eef
  java.io.NotSerializableException: javax.faces.component.html.HtmlSelectOneMenu
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
      at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
      at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:2067)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
      at org.apache.catalina.session.StandardManager.writeSessions(StandardManager.java:699)
      at org.apache.catalina.session.StandardManager.doUnloadToFile(StandardManager.java:618)
      at org.apache.catalina.session.StandardManager.unload(StandardManager.java:589)
      at org.apache.catalina.session.StandardManager.stop(StandardManager.java:879)
      at org.apache.catalina.core.StandardContext.stop(StandardContext.java:5509)
      at com.sun.enterprise.web.WebModule.stop(WebModule.java:529)
      at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1049)
      at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2191)
      at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2146)
      at com.sun.enterprise.web.WebApplication.stop(WebApplication.java:151)
      at org.glassfish.internal.data.EngineRef.stop(EngineRef.java:169)
      at org.glassfish.internal.data.ModuleInfo.stop(ModuleInfo.java:302)
      at org.glassfish.internal.data.ApplicationInfo.stop(ApplicationInfo.java:314)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.unload(ApplicationLifecycle.java:997)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.disable(ApplicationLifecycle.java:1952)
      at com.sun.enterprise.v3.server.ApplicationLoaderService.stopApplication(ApplicationLoaderService.java:443)
      at com.sun.enterprise.v3.server.ApplicationLoaderService.preDestroy(ApplicationLoaderService.java:411)
      at com.sun.hk2.component.AbstractCreatorInhabitantImpl.dispose(AbstractCreatorInhabitantImpl.java:83)
      at com.sun.hk2.component.SingletonInhabitant.release(SingletonInhabitant.java:81)
      at com.sun.hk2.component.EventPublishingInhabitant.release(EventPublishingInhabitant.java:108)
      at com.sun.hk2.component.LazyInhabitant.release(LazyInhabitant.java:133)
      at com.sun.enterprise.v3.server.AppServerStartup.stop(AppServerStartup.java:415)
      at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.stop(GlassFishImpl.java:88)
      at com.sun.enterprise.v3.admin.StopServer.doExecute(StopServer.java:70)
      at com.sun.enterprise.v3.admin.StopDomainCommand.execute(StopDomainCommand.java:95)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.run(CommandRunnerImpl.java:383)
  </code></pre>