Thoughts on software development and other stuff

Archive for March, 2009

Using Coherence*Web with JSF

with 4 comments

Recently I was helping a customer install Coherence*Web on a JSF application. After running the install and deploying the war file, I saw the following exception:

javax.servlet.ServletException: Error while saving state in 'session': 'session attribute for name "/Page1.jsp" does not implement Serializable; class: Class javax.faces.component.UIViewRoot

HTTP session attributes must be serializable in order to place them into a distributed cache. This requirement is not unique to Coherence*Web, any session replication solution will require this in order to replicate sessions to another JVM.

However, Coherence*Web does have a feature that can let you work around this. If you place a non serializable attribute into an HTTP session with sticky session optimization enabled (see description of this feature at the bottom of this link), the attribute will be placed in a local cache (and a warning will be logged.) The idea is that if a sticky load balancer is managing the traffic, the chances are very good that subsequent requests for that session will go to the same JVM which is holding that attribute in memory. Obviously if the load balancer sends the request to another JVM (or if the JVM leaves the cluster) that session attribute will not be available in the request. Therefore this is not a recommended approach; this feature is meant to ease the transition of a web application from a single JVM to a distributed environment.

So it appears that JSF is placing some sort of view metadata into the session that isn’t serializable. The good news is that JSF can be configured to store this data on the client side (as a hidden form field) instead of the server side (in a session.) This change needs to be made in web.xml; change this:


to this:


More information on this setting can be found here:


I do find it odd however that they have the ability to write out the state to the client, but the object that holds this state isn’t serializable for some reason. I wonder if this was an oversight or if this is by design.

Written by Patrick Peralta

March 7th, 2009 at 9:06 pm

Real Men of Genius (TM)

without comments

This morning it isn’t just the weather that is rough out here in New England; apparently the weather coverage is even more so. Ouch.

Written by Patrick Peralta

March 2nd, 2009 at 10:07 am

Posted in General