【问题标题】:Debug ServletContextListener.contextDestroyed() by setting the breaking point in eclipse通过在eclipse中设置断点来调试ServletContextListener.contextDestroyed()
【发布时间】:2012-02-06 19:35:39
【问题描述】:

我实现了一个自定义 ServletContextListener 并将断点放置在 contextInitialized() 和 contextDestroyed() 上。

当使用 WTP 启动 Web 应用程序时,contextInitialized() 可以被调试器停止。但是当我关闭 Web 应用程序时,contextDestroyed() 中的断点不起作用,Web 应用程序刚刚关闭。是否有可能以及如何使用调试器在 eclipse 中调试contextDestroyed()?

我想检查在关闭Web应用程序期间是否可以正常释放使用的资源。

【问题讨论】:

  • 您是否尝试创建一个新的空 webapp 项目并尝试调试 contextDestroyed?

标签: java eclipse debugging servlets servlet-listeners


【解决方案1】:

contextDestroyed() 只会在您通过打开 Servers 视图并右键单击服务器实例并选择 Stop 或点击Servers 视图中的红色按钮,其工具提示为 Stop the server。

当您通过点击工具提示为 Terminate 的 Console 视图中的红色按钮完全终止服务器时,它将不被调用。终止(杀死)不等于停止。

【讨论】:

  • Balusc:contextDestroyed()方法中的代码因为终止(killing)而没有被执行,那么contextInitialized()方法中正在初始化的所有对象都会被销毁吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-01-18
  • 2010-12-13
  • 1970-01-01
  • 2010-10-14
  • 2015-12-28
  • 1970-01-01
  • 2011-05-13
相关资源
最近更新 更多