10

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.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Tim Lammarsch
  • 161
  • 1
  • 1
  • 10
  • I'm getting this as well, but with Tomcat 9 and on linux (not running through eclipse). It happens when I deploy a new war file. – Edward Aug 27 '22 at 10:57
  • We started experiencing the same problem. No code changes at all, and the builds just started failing around 8/16-8/18. We can even deploy an old build and that works fine. We can deploy inside of IntelliJ, but when it goes out to an actual server it fails (opposite of you). We are running our server on AWS Elastic Beanstalk with Tomcat 8.5, Corretto 11, on Amazon Linux 2 Does your app use JAXB ? – woodvi Aug 28 '22 at 23:09
  • I'm using org.glassfish.jaxb:jaxb-runtime:4.0.0. I intend to compare some different Tomcat minor revisions, but I have not found the time yet. I hope that will be possible quicker with Eclipse 2022-09, currently I could only install newer Tomcat releases by hand. – Tim Lammarsch Aug 29 '22 at 09:18

1 Answers1

9

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)

Glucide
  • 279
  • 2
  • 5
  • 1
    I was now able to upgrade to Tomcat 10.0.23. The error is gone. It is not exactly the same, but it seems that upgrading to the latest subversion is always the right idea, thus, the problem does not seem be need "solving". – Tim Lammarsch Sep 19 '22 at 15:14
  • Upgrading my local development Tomcat 10.0.14 to 10.0.23 solved the same problem for me with Eclipse 2022-09. ✓ – MrSnrub Oct 26 '22 at 20:01
  • I had the same issue with Tomcat 9.063 and it was solved in 9.0.64 as well – lechonex Nov 24 '22 at 13:55