Details
Description
My application is configured this way:
- server-side state saving
- disabled view state serialization
- custom Spring scope for a view scope as described in Cagatay's blog
(http://cagataycivici.wordpress.com/2010/02/17/port-jsf-2-0s-viewscope-to-spring-3-0/)
If the ErrorPageWriter creates an error page and a non-serializable bean is in the view scope, the ErrorPageWriter fails with the following exception:
java.io.NotSerializableException: <one.of.my.beans>
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at java.util.HashMap.writeObject(HashMap.java:1001)
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:1461)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at org.apache.myfaces.shared_impl.util.StateUtils.getAsByteArray(StateUtils.java:273)
at org.apache.myfaces.renderkit.ErrorPageWriter._writeComponent(ErrorPageWriter.java:642)
at org.apache.myfaces.renderkit.ErrorPageWriter.debugHtml(ErrorPageWriter.java:283)
at org.apache.myfaces.renderkit.ErrorPageWriter.debugHtml(ErrorPageWriter.java:250)
at org.apache.myfaces.renderkit.ErrorPageWriter.handleThrowable(ErrorPageWriter.java:417)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:274)
[...]
This exception completely masks the primary exception that caused the ErrorPageWriter to jump in. This makes it very difficult to find the root cause of the problem.
The current workaround is to disable the MyFaces error handler by setting org.apache.myfaces.ERROR_HANDLING to 'false'.