I've been attempting to solve all memory leaks that prevent an application from reloading successfully on tomcat.
I first started with Tomcat logs saying the application had a thread that didn't stop (Eclipse EMF Reference Cleaner had to be disabled with org.eclipse.emf.common.util.ReferenceClearingQueue=false).
Then solving 2 ThreadLocals not properly handled on some libraries (updating them solved it).
Then, with the help of Eclipse Memory Analyzer (MAT) i found that the classloader was being retained by a JVM shutdownhook that Log4J2 uses (Programmatically disabling shutdown hook in log4j 2).
And now i don't get any Tomcat warning and MAT can't find any references to my classes other than weak/soft, but it still does not get Gargage Collected.
With MAT i can confirm that all my classes are retained twice:
I have updated to latests Tomcat 9.0.74 and Eclipse Adoptium jdk-8.0.372.7-hotspot, but nothing has changed.
Tomcat logs don't show anything relevant on app restart (they did before solving thread locals and thread stopping)
abr 24, 2023 12:19:41 PM org.apache.catalina.core.StandardContext reload
INFORMACIÓN: Ha comenzado la recarga de Contexto [/test]
abr 24, 2023 12:19:41 PM com.sun.xml.ws.transport.http.servlet.WSServletDelegate destroy
INFORMACIÓN: WSSERVLET15: el servlet de JAX-WS se ha destruido
abr 24, 2023 12:19:41 PM com.sun.xml.ws.server.WSEndpointImpl closeManagedObjectManager
INFORMACIÓN: Closing Metro monitoring root: com.sun.metro:pp=/,type=WSEndpoint,name=/test-TestServerImplService-TestServerImplPort
abr 24, 2023 12:19:41 PM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextDestroyed
INFORMACIÓN: WSSERVLET13: el listener de contexto de JAX-WS se ha destruido
abr 24, 2023 12:20:06 PM org.apache.jasper.servlet.TldScanner scanJars
INFORMACIÓN: Al menos un JAR, que se ha explorado buscando TLDs, aún no contenía TLDs. Activar historial de depuración para este historiador para una completa lista de los JARs que fueron explorados y de los que nos se halló TLDs. Saltarse JARs no necesarios durante la exploración puede dar lugar a una mejora de tiempo significativa en el arranque y compilación de JSP .
abr 24, 2023 12:20:17 PM com.sun.xml.ws.server.MonitorBase createRoot
INFORMACIÓN: Metro monitoring rootname successfully set to: com.sun.metro:pp=/,type=WSEndpoint,name=/test-TestServerImplService-TestServerImplPort
abr 24, 2023 12:20:18 PM com.sun.xml.ws.transport.http.servlet.WSServletDelegate <init>
INFORMACIÓN: WSSERVLET14: inicializando el servlet de JAX-WS
abr 24, 2023 12:20:20 PM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
INFORMACIÓN: WSSERVLET12: inicializando el listener de contexto de JAX-WS
abr 24, 2023 12:20:20 PM org.apache.catalina.core.StandardContext reload
INFORMACIÓN: Se ha completado la recarga de este Contexto