ClassCastException when using DynaCache across web applications
 Technote (troubleshooting)
 
Problem(Abstract)
ClassCastException occurs when application A stores an object in DynaCache instance and application B retrieves the object from Dynacache and attempts to cast it to proper type.
 
Resolving the problem
By default, each application will have a separate ClassLoader. If you have common classes visible to web application classloader, then you may encounter ClassCastExceptions.

To fix this problem, there are two recommended solutions:

1. Covert the object into byte array stream and store in DynaCache. Application must serialize the object before adding in cache and de-serialize after retrieving from cache. This is the preferred method.

2. Create a shared library for the common classes and associate the shared library for a classloader at server level. This will avoid ClassLoader conflicts and will not cause ClassCastExceptions. The disadvantage of using this technique is that the class needs to be visible at server level. This may not be preferred if the same type of class needs to be present at various versions in different applications.

 
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > Dynamic Cache
Operating system(s): z/OS
Software version: 6.1
Software edition:
Reference #: 1261441
IBM Group: Software Group
Modified date: Jun 8, 2007