Indeed the servlet#destroy() method is called.


That is however not the issue I was troubleshooting, I just mentioned it as
an example of a method I can't debug since the debug session is killed
before hitting the servlet#destroy() method.

What I am actually was trying to troubleshoot is spring context cleanup
which seems to happen after the servlet cleanups. Here e.g. the stacktrace
I was tackling:



java.lang.NullPointerException

                    at
java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1106)

                    at
java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1097)

                    at
org.apache.cxf.transport.http.DestinationRegistryImpl.removeDestination(DestinationRegistryImpl.java:67)

                    at
org.apache.cxf.transport.http.AbstractHTTPDestination.deactivate(AbstractHTTPDestination.java:942)

                    at
org.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:65)

                    at
org.apache.cxf.endpoint.ServerImpl.stop(ServerImpl.java:187)

                    at
org.apache.cxf.endpoint.ServerImpl.destroy(ServerImpl.java:193)

                    at
org.apache.cxf.bus.managers.ServerRegistryImpl.preShutdown(ServerRegistryImpl.java:88)

                    at
org.apache.cxf.bus.managers.CXFBusLifeCycleManager.preShutdown(CXFBusLifeCycleManager.java:97)

                    at
org.apache.cxf.bus.extension.ExtensionManagerBus.shutdown(ExtensionManagerBus.java:289)

                    at
org.apache.cxf.bus.extension.ExtensionManagerBus.shutdown(ExtensionManagerBus.java:276)

                    at
org.apache.cxf.bus.spring.SpringBus.onApplicationEvent(SpringBus.java:108)

                    at
org.apache.cxf.bus.spring.SpringBus$1.onApplicationEvent(SpringBus.java:57)

                    at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)

                    at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335)

                    at
org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1059)

                    at
org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1020)

                    at
org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:586)

                    at
org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)

                    at
org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4839)

                    at
org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)

                    at
org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)

                    at
org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1439)

                    at
org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1428)

                    at
java.util.concurrent.FutureTask.run(FutureTask.java:266)

                    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

                    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

                    at java.lang.Thread.run(Thread.java:748)



In the meantime I know why the NPE occurs, but it bothered me that I
couldn’t debug through it (debug session got killed before hitting any
breakpoint I activated, e.g. in Serverimpl#stop()).



-----Original Message-----
From: Mark Thomas <ma...@apache.org>
Sent: woensdag 8 juni 2022 14:23
To: users@tomcat.apache.org
Subject: Re: Debugging Tomcat during shutdown



On 08/06/2022 11:54, Jean Pierre URKENS wrote:

> Hi Mark,

>

> I know the version is quite old, but that is what the client currently

> has installed.



ACK.



> I  am shutting Tomcat down with ${TOMCAT_HOME}/bin/shutdown.sh (RHEL

> 7.x server).



Good. I think that is likely to be the best option in this case.



> We've got TOMCAT_HOME under '/opt/tomcat8' and several TOMCAT_BASE

> server instances.



When you say servlet clean-up actions, what exactly do you mean? The

Servlet.destroy() method?



Generally, I'd recommend a ServletContextListener for resource clean-up.

Partly that is personal preference - I find it cleaner if all the code is
in one place - and partly it is avoiding potential issues around containers
destroying unused servlets while the web app is running. Most

(all) containers won't do this but you never know.



Meanwhile, I'm planning on some local testing to see if I can recreate the
issue you are seeing.



Mark





>

> J.P.

>

>

>

> -----Original Message-----

> From: Mark Thomas <ma...@apache.org>

> Sent: woensdag 8 juni 2022 12:45

> To: users@tomcat.apache.org

> Subject: Re: Debugging Tomcat during shutdown

>

> On 08/06/2022 11:29, Jean Pierre URKENS wrote:

>> I am trying to debug the cleanup of resources during a shutdown of

>> Tomcat

>> 8.5.43

>

> That is a rather old version. I'd recommend upgrading.

>

>> and notices that my debug session gets killed prior to performing any

>> servlet cleanup actions.

>>

>> I am starting Tomcat in debug mode with the JVM options:

>>

>> JAVA_OPTS="$JAVA_OPTS -Xdebug

>> -Xrunjdwp:transport=dt_socket,address=xxxx,server=y,suspend=n"

>>

>> Is this normal behavior? How do I debug tomcat in this scenario.

>

> How are you triggering shutdown?

>

> Mark

>

> ---------------------------------------------------------------------

> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org

> For additional commands, e-mail: users-h...@tomcat.apache.org

>

> ---------------------------------------------------------------------

> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org

> For additional commands, e-mail: users-h...@tomcat.apache.org

>



---------------------------------------------------------------------

To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org

For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to