|
| Problem | Persistent sessions are enabled and a java.io.NotSerializableException occurs. Following is an example:
[10/4/02 10:11:10:172 EDT] 28b7c18b SessionContex X WTRN0047E:
java.io.NotSerializableException: COM.ibm.db2.jdbc.app.DB2Connection
The class name at the end of the exception is the object that does not implement the serializable interface. In most instances, this object is the attribute that you put into the session object; however, sometimes this object is referenced by an attribute of the session object. To determining which attribute of the session object references this non-serializable object, you can deploy the SessionInspectServlet. | | | | Solution | - Implement the serializable interface
With persistent sessions enabled, any object that is put into the HTTPSesion must implement the serializable interface.
For example:
public classMattObject implementsSerializable{
}//end of class MattObject
Check that all objects placed in the HTTPSession implement the serializable interface.
- Deploy the SessionInspectServlet
If the class name printed in the exception is not an object that is explicitly placed into the HTTPSession, use the SessionInspectServlet to determine the attribute in the HTTPSession that references a non-serializable object.
SessionInspectServlet helps application writers to determine if application is written to support session persistence. SessionInspectServlet helps to:
- Determine attributes present in the session
- Determine serializable and non-serializable attributes in the session
- Determine the size of each serializable attribute in session
- Determine if serializable attribute is implemented properly (if serializable attribute and all its internals are serializable)
Servlet serializes and deserializes attributes into memory to simulate session persistence; therefore, application writers need not turn on session persistence to run this servlet. However, you can run it with persistent sessions enabled.
How to use the servlet in WebSphere Application Server V3.5:
- Drop the servlet classes (attached in this document) into your Web application classpath
- Define a servlet/uri entry for class SessionInspectServlet. If the Invoker Servlet is installed, servlet/uri definition is not needed.
- Restart your Web module.
- Open a browser and access your Web module from the browser, then navigate the application in the browser to populate the session.
- Press Crtl+N to open a new browser, then access the SessionInspectServlet in the new browse by calling the uri that you defined in step 2. If you are using invoker the URI will be "<webapp context root>\servlet\SessionInspectServlet". This displays the session details at that moment. You can access the servlet as you navigate your application to determine the session contents as you go along.
How to use the servlet in WebSphere Application Server V4:
- Drop the servlet classes (attached in this document) into your Web application WEB-INF/classes folder.
- Define a servlet/uri entry for class SessionInspectServlet. If ServeServletsByClassnameEnabled is set to true (check the ibm-web-ext.xmi file in the WEB-INF directory of your webModule) in your webModule, servlet/uri definition is not needed.
- Restart your Web module.
- Open a browser and access your Web module from the browser, then navigate the application in the browser to populate the session.
- Press Crtl+N to open a new browser, then access the SessionInspectServlet in the new browse by calling the uri that you defined in step 2. If you are using invoker the URI will be "<webapp context root>\servlet\SessionInspectServlet". This displays the session details at that moment. You can access the servlet as you navigate your application to determine the session contents as you go along.
How to use the servlet in WebSphere Application Server V5:
- com.ibm.ws.webcontainer.httpsession.SessionInspectServlet is shipped with WebSphere V5. It is already in the classpath and does not need to be added to the application.
Define a servlet/uri entry for class SessionInspectServlet. If ServeServletsByClassnameEnabled is set to true (check the ibm-web-ext.xmi file in the WEB-INF directory of your webModule) in your webModule, servlet/uri definition is not needed.
- Restart your Web module.
- Open a browser and access your Web module from the browser, then navigate the application in the browser to populate the session.
- Press Crtl+N to open a new browser, then access the SessionInspectServlet in the new browse by calling the uri that you defined in step 2. If you are using ServeServletsbyClassname, the URI will be "<webapp context root>\servlet\com.ibm.ws.webcontainer.httpsession.SessionInspectServlet". This displays the session details at that moment. You can access the servlet as you navigate your application to determine the session contents as you go along.
| | | |    |
| |
|
Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, Sessions and Session Management Operating system(s): Multi-Platform Software version: 3.5, 4.0, 5.0 Software edition: Edition Independent Reference #: 1066791 IBM Group: Software Group Modified date: 2004-03-02
(C) Copyright IBM Corporation 2000, 2004. All Rights Reserved.
|