protected void doStop() throws Exception
    {
        MultiException mex=new MultiException();
        
        
        Thread thread= Thread.currentThread();
        ClassLoader lastContextLoader= thread.getContextClassLoader();
        
        try
        {
            // Context listeners
            if (_contextListeners != null)
            {
                if (_webAppHandler != null)
                {
                    ServletContextEvent event= new ServletContextEvent(getServletContext());
                    
                    for (int i= LazyList.size(_contextListeners); i-- > 0;)
                    {
                        try 
                        {
                            ((ServletContextListener)LazyList.get(_contextListeners, i)).contextDestroyed(event);
                        }
                        catch (Exception e)
                        {
                            mex.add(e);
                        }
                    }
                }
            }
            _contextListeners= null;
            
            // Stop the context
            try
            {
                super.doStop();
            }
            catch (Exception e)
            {
                mex.add(e);
            }
            
            // clean up
            clearSecurityConstraints();
            
            if (_webAppHandler != null)
                removeHandler(_webAppHandler);
            _webAppHandler= null;
            
            if (_errorPages != null)
                _errorPages.clear();
            _errorPages= null;
            
            _webApp=null;
            _webInf=null;
            
            _configurations=null;
            
        }
        finally
        {
            thread.setContextClassLoader(lastContextLoader);
        }
        
        if (mex!=null)
            mex.ifExceptionThrow();
    }