I am using Eclipse 2022-06 and Tomcat 10.0.10.
Often, when shutting down Tomcat running inside Eclipse, I get
WARNUNG: Failed to clear soft references from ObjectStreamClass$Caches for web application [ROOT]
java.lang.ClassCastException: class java.io.ObjectStreamClass$Caches$1 cannot be cast to class java.util.Map (java.io.ObjectStreamClass$Caches$1 and java.util.Map are in module java.base of loader 'bootstrap')
at org.apache.catalina.loader.WebappClassLoaderBase.clearCache(WebappClassLoaderBase.java:2363)
...
I have found this question, but it does not really apply: It's a different class (Map instead of String) and I cannot find a file called "SESSIONS.ser". I also have already removed everything from the actual web service part (so the code is doing nothing). I just have not started to remove all the jar files linked that are probably loaded automatically.
Is there any way to find out which class actually causes the problem?
By the way, if by deploying a WAR file to a Tomcat installation outside Eclipse, I was not able to reproduce the error in the log. I am unsure whether that means it does not appear.
CodePudding user response:
I got the same problem after upgrading my IDE.
After comparing the both tomcat logs, I saw that there were using 2 different jvm's.
Indeed I had upgraded the jdk and the ide!
The problem is appeared with jvm11.0.16, no exception with jvm11.0.11 even on the latest ide version.
This is the explanation, but the solution consisting to keep the old jvm may be not very good...
So I did upgrade Tomcat to the latest version (8.5.82 in my case) and it solved the problem. I guess it is due to this feature (see tomcat changelog):
Disable the memory leak correction code enabled by the Context attribute clearReferencesObjectStreamClassCaches when running on a JRE that includes a fix for the underlying memory leak. (markt)