Common Use Cases
Session replication in a clustered environment
Example log file entry:
2007-04-18 14:33:23,758 ERROR [com.icesoft.faces.facelets.D2DFaceletViewHandler] Problem in renderResponse: /facelets/template/Center.xhtml @20,36 locale="#{session.locale}" setAttribute: Non-serializable attribute
Exception stack trace that usually accompanies such logging:
java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute at org.jboss.web.tomcat.tc5.session.ClusteredSession.setAttribute(ClusteredSession.java:532) at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:129) ...
Remote EJB Call
Example log file entry:
2007-04-18 14:27:33,250 ERROR [STDERR] Caused by: org.jboss.serial.exception.SerializationException: Could not create instance of java.util.logging.Logger - java.util.logging.Logger
Cause
One or more references in the object graph are not serializable. To be serializable, an object must:
Implement the Serializable interface or inherit that implementation from its object hierarchy.
Have all nonserializable fields marked as transient.
Debugging
Following are possible techniques that can be used to help identify the nonserializable class causing the error:
Search your code base for instances of the class referenced in the log file.
Change the org.jboss.serial logging level to DEBUG in log4j.xml.
If you are using JDK 1.6 set the following JVM property to add serialization information to the stack trace: -Dsun.io.serialization.extendedDebugInfo=true
Attached is a utility class diagnostic. It can be deployed via web.xml as a listener (see class javadoc) and will attempt to serialize any object passed as a value to HttpSession.setAttribute(), logging any issues to System.out. If the passed in value is a Collection or Map, it also analyzes the contents, to help pinpoint the issue.
Comments