Correct fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50991
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 30 Mar 2011 12:48:13 +0000 (12:48 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 30 Mar 2011 12:48:13 +0000 (12:48 +0000)
Stop resource after app has finished with them but before they are unbound

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1086935 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardContext.java

index 97cbdc0..231ad3b 100644 (file)
@@ -5437,15 +5437,16 @@ public class StandardContext extends ContainerBase
             if (log.isDebugEnabled())
                 log.debug("Processing standard container shutdown");
 
-            fireLifecycleEvent(Lifecycle.CONFIGURE_STOP_EVENT, null);
-
-            // JNDI resources are unbound in CONFIGURE_STOP_EVENT so it is now
-            // safe to stop the resources which will trigger the close method if
-            // present
+            // JNDI resources are unbound in CONFIGURE_STOP_EVENT so stop
+            // naming resoucres before they are unbound since NamingResoucres
+            // does a JNDI lookup to retrieve the resource. This needs to be
+            // after the application has finished with the resource 
             if (namingResources != null) {
                 namingResources.stop();
             }
             
+            fireLifecycleEvent(Lifecycle.CONFIGURE_STOP_EVENT, null);
+
             // Stop the Valves in our pipeline (including the basic), if any
             if (pipeline instanceof Lifecycle) {
                 ((Lifecycle) pipeline).stop();