If I use @ViewScoped
in JSF, then the following exception occurs:
java.io.NotSerializableException: com.solv.basics.Basics
java.io.ObjectOutputStream.writeObject0(Unknown Source)
java.io.ObjectOutputStream.writeObject(Unknown Source)
java.util.HashMap.writeObject(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
java.io.ObjectOutputStream.writeSerialData(Unknown Source)
java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
I can solve it by letting the bean implement Serializable
. However, I do not understand the reasoning. Why does this exception only occur for the view scope and not the other scopes?