--- jakarta-tomcat-4.1.31-src/catalina/src/share/org/apache/catalina/core/StandardContext.java 2004-09-25 17:44:19.000000000 +0100 +++ jakarta-tomcat-4.1.31-src/catalina/src/share/org/apache/catalina/core/StandardContext.java 2006-03-20 07:56:05.000000000 +0000 @@ -2392,49 +2392,51 @@ // Binding thread ClassLoader oldCCL = bindThread(); - // Shut down our session manager - if ((manager != null) && (manager instanceof Lifecycle)) { - try { - ((Lifecycle) manager).stop(); - } catch (LifecycleException e) { - log(sm.getString("standardContext.stoppingManager"), e); - } - } - - // Shut down the current version of all active servlets - Container children[] = findChildren(); - for (int i = 0; i < children.length; i++) { - Wrapper wrapper = (Wrapper) children[i]; - if (wrapper instanceof Lifecycle) { + try { + // Shut down our session manager + if ((manager != null) && (manager instanceof Lifecycle)) { try { - ((Lifecycle) wrapper).stop(); + ((Lifecycle) manager).stop(); } catch (LifecycleException e) { - log(sm.getString("standardContext.stoppingWrapper", - wrapper.getName()), - e); + log(sm.getString("standardContext.stoppingManager"), e); } } - } - // Shut down application event listeners - listenerStop(); - - // Clear all application-originated servlet context attributes - if (context != null) - context.clearAttributes(); + // Shut down the current version of all active servlets + Container children[] = findChildren(); + for (int i = 0; i < children.length; i++) { + Wrapper wrapper = (Wrapper) children[i]; + if (wrapper instanceof Lifecycle) { + try { + ((Lifecycle) wrapper).stop(); + } catch (LifecycleException e) { + log(sm.getString("standardContext.stoppingWrapper", + wrapper.getName()), + e); + } + } + } - // Shut down filters - filterStop(); + // Shut down application event listeners + listenerStop(); - if (isUseNaming()) { - // Start - namingContextListener.lifecycleEvent - (new LifecycleEvent(this, Lifecycle.STOP_EVENT)); + // Clear all application-originated servlet context attributes + if (context != null) + context.clearAttributes(); + + // Shut down filters + filterStop(); + + if (isUseNaming()) { + // Start + namingContextListener.lifecycleEvent + (new LifecycleEvent(this, Lifecycle.STOP_EVENT)); + } + } finally { + // Binding thread + unbindThread(oldCCL); } - // Binding thread - unbindThread(oldCCL); - // Shut down our application class loader if ((loader != null) && (loader instanceof Lifecycle)) { try { @@ -2447,18 +2449,20 @@ // Binding thread oldCCL = bindThread(); - // Restart our application class loader - if ((loader != null) && (loader instanceof Lifecycle)) { - try { - ((Lifecycle) loader).start(); - } catch (LifecycleException e) { - log(sm.getString("standardContext.startingLoader"), e); + try { + // Restart our application class loader + if ((loader != null) && (loader instanceof Lifecycle)) { + try { + ((Lifecycle) loader).start(); + } catch (LifecycleException e) { + log(sm.getString("standardContext.startingLoader"), e); + } } + } finally { + // Binding thread + unbindThread(oldCCL); } - // Binding thread - unbindThread(oldCCL); - // Create and register the associated naming context, if internal // naming is used boolean ok = true; @@ -2471,56 +2475,58 @@ // Binding thread oldCCL = bindThread(); - // Restart our application event listeners and filters - if (ok) { - if (!listenerStart()) { - log(sm.getString("standardContext.listenerStartFailed")); - ok = false; + try { + // Restart our application event listeners and filters + if (ok) { + if (!listenerStart()) { + log(sm.getString("standardContext.listenerStartFailed")); + ok = false; + } } - } - if (ok) { - if (!filterStart()) { - log(sm.getString("standardContext.filterStartFailed")); - ok = false; + if (ok) { + if (!filterStart()) { + log(sm.getString("standardContext.filterStartFailed")); + ok = false; + } } - } - // Restore the "Welcome Files" and "Resources" context attributes - postResources(); - postWelcomeFiles(); + // Restore the "Welcome Files" and "Resources" context attributes + postResources(); + postWelcomeFiles(); - // Restart our currently defined servlets - for (int i = 0; i < children.length; i++) { - if (!ok) - break; - Wrapper wrapper = (Wrapper) children[i]; - if (wrapper instanceof Lifecycle) { - try { - ((Lifecycle) wrapper).start(); - } catch (LifecycleException e) { - log(sm.getString("standardContext.startingWrapper", - wrapper.getName()), - e); - ok = false; + // Restart our currently defined servlets + for (int i = 0; i < children.length; i++) { + if (!ok) + break; + Wrapper wrapper = (Wrapper) children[i]; + if (wrapper instanceof Lifecycle) { + try { + ((Lifecycle) wrapper).start(); + } catch (LifecycleException e) { + log(sm.getString("standardContext.startingWrapper", + wrapper.getName()), + e); + ok = false; + } } } - } - // Reinitialize all load on startup servlets - loadOnStartup(children); + // Reinitialize all load on startup servlets + loadOnStartup(children); - // Restart our session manager (AFTER naming context recreated/bound) - if ((manager != null) && (manager instanceof Lifecycle)) { - try { - ((Lifecycle) manager).start(); - } catch (LifecycleException e) { - log(sm.getString("standardContext.startingManager"), e); + // Restart our session manager (AFTER naming context recreated/bound) + if ((manager != null) && (manager instanceof Lifecycle)) { + try { + ((Lifecycle) manager).start(); + } catch (LifecycleException e) { + log(sm.getString("standardContext.startingManager"), e); + } } + } finally { + // Unbinding thread + unbindThread(oldCCL); } - // Unbinding thread - unbindThread(oldCCL); - // Start accepting requests again if (ok) { log(sm.getString("standardContext.reloadingCompleted")); @@ -3470,13 +3476,12 @@ // Binding thread ClassLoader oldCCL = bindThread(); - // Standard container startup - if (debug >= 1) - log("Processing standard container startup"); - - if (ok) { + try { + // Standard container startup + if (debug >= 1) + log("Processing standard container startup"); - try { + if (ok) { addDefaultMapper(this.mapperClass); started = true; @@ -3525,12 +3530,12 @@ if ((manager != null) && (manager instanceof Lifecycle)) ((Lifecycle) manager).start(); - } finally { - // Unbinding thread - unbindThread(oldCCL); } - + } finally { + // Unbinding thread + unbindThread(oldCCL); } + if (!getConfigured()) ok = false; @@ -3542,26 +3547,28 @@ // Binding thread oldCCL = bindThread(); - // Create context attributes that will be required - if (ok) { - if (debug >= 1) - log("Posting standard context attributes"); - postWelcomeFiles(); - } + try { + // Create context attributes that will be required + if (ok) { + if (debug >= 1) + log("Posting standard context attributes"); + postWelcomeFiles(); + } - // Configure and call application event listeners and filters - if (ok) { - if (!listenerStart()) - ok = false; - } - if (ok) { - if (!filterStart()) - ok = false; + // Configure and call application event listeners and filters + if (ok) { + if (!listenerStart()) + ok = false; + } + if (ok) { + if (!filterStart()) + ok = false; + } + } finally { + // Unbinding thread + unbindThread(oldCCL); } - // Unbinding thread - unbindThread(oldCCL); - // Set available status depending upon startup success if (ok) { if (debug >= 1) @@ -3583,8 +3590,11 @@ // Load and initialize all "load on startup" servlets oldCCL = bindThread(); - loadOnStartup(findChildren()); - unbindThread(oldCCL); + try { + loadOnStartup(findChildren()); + } finally { + unbindThread(oldCCL); + } } @@ -3612,27 +3622,27 @@ // Binding thread ClassLoader oldCCL = bindThread(); - // Stop our filters - filterStop(); + try { - // Stop our application listeners - listenerStop(); + // Stop our filters + filterStop(); - // Finalize our character set mapper - setCharsetMapper(null); + // Stop our application listeners + listenerStop(); - if ((manager != null) && (manager instanceof Lifecycle)) { - ((Lifecycle) manager).stop(); - } + // Finalize our character set mapper + setCharsetMapper(null); - // Normal container shutdown processing - if (debug >= 1) - log("Processing standard container shutdown"); - // Notify our interested LifecycleListeners - lifecycle.fireLifecycleEvent(STOP_EVENT, null); - started = false; + if ((manager != null) && (manager instanceof Lifecycle)) { + ((Lifecycle) manager).stop(); + } - try { + // Normal container shutdown processing + if (debug >= 1) + log("Processing standard container shutdown"); + // Notify our interested LifecycleListeners + lifecycle.fireLifecycleEvent(STOP_EVENT, null); + started = false; // Stop the Valves in our pipeline (including the basic), if any if (pipeline instanceof Lifecycle) {