Testing session persistence is often painful because it requires the setup of a cluster. Using the element in the web.xml you can mark your web module as distributable like so
An easy way to test your application for persistence is to set the distributable element in the web.xml and enable com.ibm.ws.session*=all trace. If objects aren't serializable, you will see error messages in the SystemOut.log like so
Errors and NPEs in HTTPSession persistence can be flushed out by making sure that that Session Manager is configured correctly. http://www.redbooks.ibm.com/redpapers/pdfs/redp4580.pdf is an excellent resource for Session Management.
Please refer to http://wiki.metawerx.net/wiki/Web.xml.Distributable for some basic guidelines when coding with HTTPSessions
1. All session attributes must be serializable (must implement java.io.Serializable). Most native java objects, including data types such as Strings and Integers implement this functionality.
2. After changing any objects which are stored in the session, HttpSession.setAttribute() must be called to inform the session replicator that the session has changed.
3. Ideally, sessions should be kept relatively small, to ensure less network traffic between the each clustered VM.
An easy way to test your application for persistence is to set the distributable element in the web.xml and enable com.ibm.ws.session*=all trace. If objects aren't serializable, you will see error messages in the SystemOut.log like so
IllegalArgumentException("Attribute
with name " + pName + " is not java.io.Serializable. All attributes
stored in session must be Serializable when web module is marked as
distributable");
You proceed to test session persistence with a single server using persistence to database or a JDBCStore(in tomcat). Errors and NPEs in HTTPSession persistence can be flushed out by making sure that that Session Manager is configured correctly. http://www.redbooks.ibm.com/redpapers/pdfs/redp4580.pdf is an excellent resource for Session Management.
Please refer to http://wiki.metawerx.net/wiki/Web.xml.Distributable for some basic guidelines when coding with HTTPSessions
1. All session attributes must be serializable (must implement java.io.Serializable). Most native java objects, including data types such as Strings and Integers implement this functionality.
2. After changing any objects which are stored in the session, HttpSession.setAttribute() must be called to inform the session replicator that the session has changed.
3. Ideally, sessions should be kept relatively small, to ensure less network traffic between the each clustered VM.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.