Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48443
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 30 Dec 2009 09:24:17 +0000 (09:24 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 30 Dec 2009 09:24:17 +0000 (09:24 +0000)
Correct FileNotFoundException on ROOT context start when annotation scanning is enabled
Patch provided by wujunchen

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

java/org/apache/naming/resources/DirContextURLConnection.java

index c76978e..33d3774 100644 (file)
@@ -426,9 +426,17 @@ public class DirContextURLConnection
         if (collection != null) {
             try {
                 String file = getURL().getFile();
-                // This will be of the form /<hostname>/<contextpath/file name
+                // This will be of the form /<hostname>/<contextpath>/file name
+                // if <contextpath> is not empty otherwise this will be of the
+                // form /<hostname>/file name
                 // Strip off the hostname and the contextpath
-                int start = file.indexOf('/', file.indexOf('/', 1) + 1);
+                int start;
+                if(context instanceof ProxyDirContext &&
+                        "".equals(((ProxyDirContext)context).getContextName())){
+                    start = file.indexOf('/',1);
+                }
+                else
+                    start = file.indexOf('/', file.indexOf('/', 1) + 1);
                 
                 NamingEnumeration<NameClassPair> enumeration =
                     context.list(file.substring(start));