14

Version Java: 10.0.1 Tomcat: 8.0.36 Ubuntu: 18.04 (64 bit) Eclipse: Photon (64 bit)

Error: When I run the Tomcat server, I found below error. Please don't tell me to decrease the version if possible, because I love to use latest technology.

    SEVERE: Failed to trigger creation of the GC Daemon thread during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs.
java.lang.ClassNotFoundException: sun.misc.GC
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:291)
at org.apache.catalina.core.JreMemoryLeakPreventionListener.lifecycleEvent(JreMemoryLeakPreventionListener.java:286)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:394)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:99)
at org.apache.catalina.startup.Catalina.load(Catalina.java:580)
at org.apache.catalina.startup.Catalina.load(Catalina.java:603)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)

1 Answers1

18

Tomcat 8 references sun.misc.GC, which was removed in Java 9 - hence you get the error.

Please don't tell me to decrease the version if possible, because I love to use latest technology.

I'll tell you to do the opposite then! You should be using Tomcat 9, not Tomcat 8. The error should then disappear.

Michael Berry
  • 70,193
  • 21
  • 157
  • 216
  • #Seems that tomcat 9 still refer to sun.misc.GC: SEVERE [main] org.apache.catalina.core.JreMemoryLeakPreventionListener.lifecycleEvent Failed to trigger creation of the GC Daemon thread during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs. java.lang.ClassNotFoundException: sun.misc.GC Server version: Apache Tomcat/9.0.13 Server built: Nov 2 2018 14:27:55 UTC Server number: 9.0.13.0 OS Name: Linux OS Version: 4.4.0-62-generic JVM Version: 9-internal+0-2016-04-14-195246.buildd.src JVM Vendor: Oracle Corporation – Liu Yi Nov 16 '18 at 09:36
  • 3
    Upgrading to tomcat 9 fixed the problem for me. Just make sure that you have all of these: locally installed openjdk 11, project facet java 11, latest tomcat 9 downloaded from apache (in some package repos, there is an errorneous version that still references sun.misc.GC) – nagylzs May 23 '19 at 05:31