Additional fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=43683
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 28 May 2008 20:42:22 +0000 (20:42 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 28 May 2008 20:42:22 +0000 (20:42 +0000)
If the context is reloaded, the classloader will have changed so need to reset it

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

java/org/apache/catalina/core/StandardContextValve.java

index cb019ce..57d86b0 100644 (file)
@@ -126,7 +126,9 @@ final class StandardContextValve
         }
 
         // Wait if we are reloading
+        boolean reloaded = false;
         while (context.getPaused()) {
+            reloaded = true;
             try {
                 Thread.sleep(1000);
             } catch (InterruptedException e) {
@@ -134,6 +136,15 @@ final class StandardContextValve
             }
         }
 
+        // Reloading will have stopped the old webappclassloader and
+        // created a new one
+        if (reloaded &&
+                context.getLoader() != null &&
+                context.getLoader().getClassLoader() != null) {
+            Thread.currentThread().setContextClassLoader(
+                    context.getLoader().getClassLoader());
+        }
+
         // Select the Wrapper to be used for this Request
         Wrapper wrapper = request.getWrapper();
         if (wrapper == null) {