ClassCastException when stopping Tomcat 10 inside Eclipse
Asked Answered
A

2

12

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.

Attendance answered 23/8, 2022 at 11:19 Comment(4)
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.Deathly
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 ?Walt
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.Attendance
Not an answer but I'm getting the same warning on shutdown of standalone (not in IDE) Tomcat 9.0.8 after upgrading from jdk1.8.0_40 to Amazon Corretto\jdk11.0.22_7Cacomistle
W
12

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)

Weikert answered 31/8, 2022 at 6:58 Comment(4)
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".Attendance
Upgrading my local development Tomcat 10.0.14 to 10.0.23 solved the same problem for me with Eclipse 2022-09. ✓Waterless
I had the same issue with Tomcat 9.063 and it was solved in 9.0.64 as wellNeuroma
This also solved it for me, going from Tomcat 9.0.31 to 9.0.91.Wirer
S
0

For us it was Spring Boot 3 which required upgrading to Jakarta EE 9+. And Jakarta EE 9+ needs Tomcat 10.1.x while we had Tomcat9 running.

So our solution was to upgrade to the latest Tomcat Version as well.

Shyamal answered 24/5, 2024 at 14:16 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.