You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Daniel McCue <dm...@gmail.com> on 2023/01/04 15:11:51 UTC

Tomcat 9.0.58 reports an error on shutdown: "Failed to clear soft references..."

Apache Tomcat/9.0.58 reports an error on shutdown: "Failed to clear soft
references from ObjectStreamClass$Caches for web application [ROOT]"

The error is reported for web applications: [ROOT], [host-manager], and
[manager] -- the only applications deployed in Tomcat.

The traceback shows a ClassCastException in
org.apache.catalina.loader.WebappClassLoaderBase.clearCache

I have searched the FAQ, configuration documentation, and web (google
search), but found only framework-specific solutions like "delete the
directory, CATALINA_BASE/conf/Catalina/localhost/awi", which doesn't exist
in my configuration.

There is a reference to ClassCastExceptions in the release notes for Tomcat
9.0.70, but it suggests moving app-specific .jar files to the shared
loader.  I have loaded none of my own apps -- only the ones that come with
tomcat and tomcat-admin.  I cannot find any app-specific .jar files in
Catalina.properties or anywhere in CATALINA_BASE or its subdirectories.

I have updated all software on my Ubuntu machine as of today (4-jan-2022)
using "sudo apt-get update; sudo apt-get upgrade".
I have rebooted the machine and ensured that no files existed in
CATALINA_BASE/lib, but the problem persists.

How can I find my configuration error or stale cache data or somehow clean
up the shutdown process?

I'm running Apache Tomcat 9.0.58 on Ubuntu 22 LTS with openjdk-11 on an AMD
64-bit processor.
Both the tomcat package and the openjdk package were loaded using apt-get
from the standard Ubuntu repository for Ubuntu 22.

Apache Tomcat server startup is normal (no errors reported), but every time
it shuts down, errors are reported in catalina.out.
See the configuration and error traceback below.

----------------------------------------------
The configuration as reported in catalina.out:

[info] Server version name:    Apache Tomcat/9.0.58 (Ubuntu)
[info] Server built:                 Jan 6 1970 15:09:28 UTC
[info] Server version number: 9.0.58.0
[info] OS Name:                    Linux
[info] OS Version:                  5.15.0-56-generic
[info] Architecture:                amd64
[info] Java Home:                  /usr/lib/jvm/java-11-openjdk-amd64
[info] JVM Version:                11.0.17+8-post-Ubuntu-1ubuntu222.04
[info] JVM Vendor:                 Ubuntu
[info] CATALINA_BASE:          /var/lib/tomcat9
[info] CATALINA_HOME:         /usr/share/tomcat9
[info] Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
[info] Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
[info] Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
[info] Command line argument:
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
[info] Command line argument:
--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
[info] Command line argument:
-Djava.util.logging.config.file=/var/lib/tomcat9/conf/logging.properties
[info] Command line argument:
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
[info] Command line argument: -Djava.awt.headless=true
[info] Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
[info] Command line argument:
-Djava.protocol.handler.pkgs=org.apache.catalina.webresources
[info] Command line argument:
-Dorg.apache.catalina.security.SecurityListener.UMASK=0027
[info] Command line argument: -Dignore.endorsed.dirs=
[info] Command line argument: -Dcatalina.base=/var/lib/tomcat9
[info] Command line argument: -Dcatalina.home=/usr/share/tomcat9
[info] Command line argument: -Djava.io.tmpdir=/tmp
[info] Loaded Apache Tomcat Native library [1.2.31] using APR version
[1.7.0].
[info] APR capabilities: IPv6 [true], sendfile [true], accept filters
[false], random [true], UDS [true].
[info] APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
[info] OpenSSL successfully initialized [OpenSSL 3.0.2 15 Mar 2022]

-----------------------------------------
When the service is shut down using '$ sudo service tomcat9 stop', errors
are reported in catalina.out as:

[info] Pausing ProtocolHandler ["http-nio-8080"]
[info] Stopping service [Catalina]
[warning] Failed to clear soft references from ObjectStreamClass$Caches for
web application [ROOT]
[warning] 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')
[warning]     at
org.apache.catalina.loader.WebappClassLoaderBase.clearCache(WebappClassLoaderBase.java:2325)
[warning]     at
org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesObjectStreamClassCaches(WebappClassLoaderBase.java:2300)
[warning]     at
org.apache.catalina.loader.WebappClassLoaderBase.clearReferences(WebappClassLoaderBase.java:1669)
[warning]     at
org.apache.catalina.loader.WebappClassLoaderBase.stop(WebappClassLoaderBase.java:1597)
[warning]     at
org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:463)
[warning]     at
org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
[warning]     at
org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5515)
[warning]     at
org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
[warning]     at
org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1412)
[warning]     at
org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1401)
[warning]     at
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[warning]     at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
[warning]     at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
[warning]     at
org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:986)
[warning]     at
org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
[warning]     at
org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1412)
[warning]     at
org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1401)
[warning]     at
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[warning]     at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
[warning]     at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
[warning]     at
org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:986)
[warning]     at
org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
[warning]     at
org.apache.catalina.core.StandardService.stopInternal(StandardService.java:497)
[warning]     at
org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
[warning]     at
org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:979)
[warning]     at
org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
[warning]     at
org.apache.catalina.startup.Catalina.stop(Catalina.java:849)
[warning]     at
org.apache.catalina.startup.Catalina$CatalinaShutdownHook.run(Catalina.java:996)

Re: Tomcat 9.0.58 reports an error on shutdown: "Failed to clear soft references..."

Posted by Daniel McCue <dm...@gmail.com>.
Thank you, Mark!
This answers my question and offers two (three) good solutions.
I appreciate the quick, accurate, and constructive response.

Dan

On Wed, Jan 4, 2023 at 10:38 AM Mark Thomas <ma...@apache.org> wrote:

> On 04/01/2023 15:11, Daniel McCue wrote:
> > Apache Tomcat/9.0.58 reports an error on shutdown: "Failed to clear soft
> > references from ObjectStreamClass$Caches for web application [ROOT]"
> >
> > The error is reported for web applications: [ROOT], [host-manager], and
> > [manager] -- the only applications deployed in Tomcat.
> >
> > The traceback shows a ClassCastException in
> > org.apache.catalina.loader.WebappClassLoaderBase.clearCache
> >
> > I have searched the FAQ, configuration documentation, and web (google
> > search), but found only framework-specific solutions like "delete the
> > directory, CATALINA_BASE/conf/Catalina/localhost/awi", which doesn't
> exist
> > in my configuration.
> >
> > There is a reference to ClassCastExceptions in the release notes for
> Tomcat
> > 9.0.70, but it suggests moving app-specific .jar files to the shared
> > loader.  I have loaded none of my own apps -- only the ones that come
> with
> > tomcat and tomcat-admin.  I cannot find any app-specific .jar files in
> > Catalina.properties or anywhere in CATALINA_BASE or its subdirectories.
> >
> > I have updated all software on my Ubuntu machine as of today (4-jan-2022)
> > using "sudo apt-get update; sudo apt-get upgrade".
> > I have rebooted the machine and ensured that no files existed in
> > CATALINA_BASE/lib, but the problem persists.
> >
> > How can I find my configuration error or stale cache data or somehow
> clean
> > up the shutdown process?
>
> There is no configuration error.
>
> There is no stale cache data.
>
> The warning results from using a JRE that includes a fix for [1]
> https://bugs.openjdk.org/browse/JDK-8277072
>
> Newer versions of Tomcat that have [2] (9.0.64 onwards) check for the
> fix and don't attempt to clear the cache if the fix is present.
>
> You can just ignore the warning.
>
> If you want to silence the warning you can set the context attribute
> clearReferencesObjectStreamClassCaches="false"
>
> Mark
>
> [1] https://bugs.openjdk.org/browse/JDK-8277072
> [2]
>
> https://github.com/apache/tomcat/commit/385d4095ccf354c2f9c527283f3ed2832de1a1cf
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tomcat 9.0.58 reports an error on shutdown: "Failed to clear soft references..."

Posted by Mark Thomas <ma...@apache.org>.
On 04/01/2023 15:11, Daniel McCue wrote:
> Apache Tomcat/9.0.58 reports an error on shutdown: "Failed to clear soft
> references from ObjectStreamClass$Caches for web application [ROOT]"
> 
> The error is reported for web applications: [ROOT], [host-manager], and
> [manager] -- the only applications deployed in Tomcat.
> 
> The traceback shows a ClassCastException in
> org.apache.catalina.loader.WebappClassLoaderBase.clearCache
> 
> I have searched the FAQ, configuration documentation, and web (google
> search), but found only framework-specific solutions like "delete the
> directory, CATALINA_BASE/conf/Catalina/localhost/awi", which doesn't exist
> in my configuration.
> 
> There is a reference to ClassCastExceptions in the release notes for Tomcat
> 9.0.70, but it suggests moving app-specific .jar files to the shared
> loader.  I have loaded none of my own apps -- only the ones that come with
> tomcat and tomcat-admin.  I cannot find any app-specific .jar files in
> Catalina.properties or anywhere in CATALINA_BASE or its subdirectories.
> 
> I have updated all software on my Ubuntu machine as of today (4-jan-2022)
> using "sudo apt-get update; sudo apt-get upgrade".
> I have rebooted the machine and ensured that no files existed in
> CATALINA_BASE/lib, but the problem persists.
> 
> How can I find my configuration error or stale cache data or somehow clean
> up the shutdown process?

There is no configuration error.

There is no stale cache data.

The warning results from using a JRE that includes a fix for [1] 
https://bugs.openjdk.org/browse/JDK-8277072

Newer versions of Tomcat that have [2] (9.0.64 onwards) check for the 
fix and don't attempt to clear the cache if the fix is present.

You can just ignore the warning.

If you want to silence the warning you can set the context attribute 
clearReferencesObjectStreamClassCaches="false"

Mark

[1] https://bugs.openjdk.org/browse/JDK-8277072
[2] 
https://github.com/apache/tomcat/commit/385d4095ccf354c2f9c527283f3ed2832de1a1cf

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org