Error : non-serializable attribute value into ViewMap

雨燕双飞 提交于 2019-11-30 20:24:49

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.

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.

Misiakw

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!