Error : non-serializable attribute value into ViewMap

后端 未结 3 1277
天命终不由人
天命终不由人 2021-01-05 15:42

i have the same application in 2 systems(laptops) but its working in one but not in another.i get the following error in another system. i have also posted the code below.wh

相关标签:
3条回答
  • 2021-01-05 15:51

    Anything which is added to session is Serialized. The error is telling you that your backing bean should probably be Serializable. No idea why it's intermittent though.

    0 讨论(0)
  • 2021-01-05 16:01

    Some server configurations need to save HTTP sessions on harddisk or need to transfer them over network to some central datastore, often with the goal to share the session between multiple servers in a cluster, or to minimize excessive memory usage. This in turn requires that all session attributes implement Serializable so that the server could use ObjectOutputStream to convert Java objects to bytes which can then be saved on disk or transferred over network and ObjectInputStream to convert those bytes back to Java objects.

    If an object which is stored in the HTTP session does not implement Serializable, then you will get a NotSerializableException with the full qualified class name in the message. You should then fix the class to implement Serializable.

    public class StockOrderBean implements Serializable {
        // ...
    }
    

    In JSF, this applies to all view and session scoped managed beans. Request and application scoped beans doesn't need to implement Serializable. Note that all of the bean properties should also be Serializable. But you will get a clear enough NotSerializableException whenever one is encountered.

    0 讨论(0)
  • 2021-01-05 16:08

    Try adding the code below to your web.xml. It will keep session objects on server side.

    <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>server</param-value>
    </context-param>
    
    0 讨论(0)
提交回复
热议问题