I'm in a very interesting situation. I'm validating the migration tomcat 6 to tomcat 7, so we can use the zero donwtime deploy.
One of the problematic situations is our cache. As we'll have two wars running at the same address int tomcat 7... the cache will be doubled! Cache today is inside servlet context.
The first idea I had was to put the cache within the global JNDI. Thus, all. War can access the same cache in the global JNDI container.
I work, but the problem came .... When I retrieve an object inserted by another war, the JVM generates another internal identifier for the same class in both wars....and so all my cast crashed!!! Especially those inside equals .....That is, within the cache I have an object of class war within thecom.empresa.Cliente ....., I have the same class does not work just right ... but the cast!Any idea how to get around this?
That is correct, two different web applications (even the same application deployed twice) generates to different classes, as the same class is loaded by the same class loader.
If you want your cache to remain up, while you redeploy the application, you would also have to extract the classes stored in the cache, remove them from the WAR and deploy those classes into tomcat's lib directory instead. These classes wont be reloaded, nor will they change.