Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug ServletContextListener.contextDestroyed() by setting the breaking point in eclipse

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.

like image 521
Ken Chan Avatar asked Jan 10 '12 11:01

Ken Chan


People also ask

How do I enable debug breakpoints in eclipse?

Breakpoints To define a breakpoint in your source code, right-click in the left margin in the Java editor and select Toggle Breakpoint. Alternatively, you can double-click on this position. The Breakpoints view allows you to delete and deactivate Breakpoints and modify their properties.

How do I move a breakpoint from one eclipse to another?

Press F8 (which is also Resume button),that will take you to the break point. From there debug each line with F6. If you want to go to next break point press F8.


1 Answers

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.

like image 74
BalusC Avatar answered Sep 22 '22 17:09

BalusC