---
title: "tomcat 停止的时候 contextDestroyed不执行(转)"
author: "javaEEdevelop"
date: "2013-03-22T08:43:43Z"
tags: []
categories: ["开源软件"]
slug: "tomcat-contextdestroyed"
draft: false
lastmod: "2013-03-17T18:36:59Z"
id: 1830819
url: "https://javaeedevelop.iteye.com/blog/1830819"
---

最近在做一个监听器，

 public void contextInitialized(ServletContextEvent sce) {

}

当TOMCAT启动时这个方法里的程序执行了，但是当服务器停止时下面这个方法没有执行！让我很郁闷。

后来才知道原因

public void contextDestroyed(ServletContextEvent sce) {  
  System.err.println("服务器开始停止运行");

}

 

原来我是用myEclipse集成了tomcat ，在这个开发坏境里是不能运行contextDestroyed的。

呵呵，直接启动安装的tomcat 即可。