Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51741
authorslaurent <slaurent@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 31 Aug 2011 20:35:22 +0000 (20:35 +0000)
committerslaurent <slaurent@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 31 Aug 2011 20:35:22 +0000 (20:35 +0000)
bug 51741: Eclipse WTP "Serve modules without publishing" broken with tc7, needs patch in tomcat

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

java/org/apache/catalina/loader/WebappClassLoader.java

index dbb15a2..d94b1a9 100644 (file)
@@ -2898,11 +2898,22 @@ public class WebappClassLoader
 
                 // Note : Not getting an exception here means the resource was
                 // found
-                entry = findResourceInternal(files[i], path);
 
                 ResourceAttributes attributes =
                     (ResourceAttributes) resources.getAttributes(fullPath);
                 contentLength = (int) attributes.getContentLength();
+                String canonicalPath = attributes.getCanonicalPath();
+                if (canonicalPath != null) {
+                    // we create the ResourceEntry based on the information returned
+                    // by the DirContext rather than just using the path to the
+                    // repository. This allows to have smart DirContext implementations 
+                    // that "virtualize" the docbase (e.g. Eclipse WTP)
+                    entry = findResourceInternal(new File(canonicalPath), "");
+                } else {
+                    // probably a resource not in the filesystem (e.g. in a
+                    // packaged war)
+                    entry = findResourceInternal(files[i], path);
+                }
                 entry.lastModified = attributes.getLastModified();
 
                 if (resource != null) {