Question

I implement a custom ServletContextListener and place the breakpoints on both the contextInitialized() and contextDestroyed().

When starting the web application using WTP , contextInitialized() can be stopped by the debugger. But when I shut down the web application , the breakpoints in the contextDestroyed() do not work and the web application just shutdown . Is it possible and how to use debugger to debug contextDestroyed() in eclipse ?

I want to check if the resource used can be released properly during the shut-down of the web application.

Was it helpful?

Solution

The contextDestroyed() will only be called when you gracefully shuts down the server by opening the Servers view and rightclicking the server instance and choosing Stop, or by hitting the red button in the Servers view whose tooltip says Stop the server.

It will not be called when you terminate the server altogether by hitting the red button in the Console view whose tooltip says Terminate. Terminating (killing) is not the same as stopping.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top