title: GSON not serializable in JSF managed bean
body: <p>I am using GSON. When I start tomcat it gives me error. Part of my code:</p>
  
  <pre><code> @ManagedBean(name = "kpilist")
  @ViewScoped
  public class KPIListController implements Serializable {
  
      public List&lt;KPI&gt; getKPI() {
          KPIDAO kpiDAO = new KPIDAO();        
          List&lt;KPI&gt; kpiList = new ArrayList&lt;KPI&gt;();
           Gson gson = new Gson();  
          try {
              kpiList = kpiDAO.getKPI(selectedKPIType);     
              json = gson.toJson(kpiList) ;
              Logger.getLogger(KPIListController.class.getName()).warning("The KPI JSON" + json);
          } catch (SQLException ex) {
              ex.printStackTrace();
              return null;
          }
          return kpiList;
      }
  </code></pre>
  
  <hr>
  
  <pre><code>WARNING: Cannot serialize session attribute com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap for session 41AC6C7AB4B0869A29778EA4155BFCA1
      java.io.NotSerializableException: com.google.gson.Gson
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
          at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
          at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
          at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
          at java.util.HashMap.writeObject(HashMap.java:1014)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:601)
          at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
          at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
          at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
          at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
          at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
          at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
          at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)
          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
          at java.util.HashMap.writeObject(HashMap.java:1014)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:601)
          at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
          at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
          at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
          at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)
          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
          at java.util.HashMap.writeObject(HashMap.java:1014)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:601)
          at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
          at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
          at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
          at java.util.HashMap.writeObject(HashMap.java:1014)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:601)
          at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
          at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
          at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
          at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1692)
          at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1092)
          at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:411)
          at org.apache.catalina.session.StandardManager.unload(StandardManager.java:353)
          at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:497)
          at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
          at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5449)
          at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
          at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1540)
          at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1530)
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
          at java.util.concurrent.FutureTask.run(FutureTask.java:166)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
          at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>Did I do any mistake in using GSON?</p>