Author: markt
Date: Thu Feb 28 00:53:29 2013
New Revision: 1451065

URL: http://svn.apache.org/r1451065
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54585
Take account of setting of delegate when building the class path that is passed 
to Jasper

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1451053,1451061

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java?rev=1451065&r1=1451064&r2=1451065&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java Thu 
Feb 28 00:53:29 2013
@@ -1041,44 +1041,27 @@ public class WebappLoader extends Lifecy
 
         // Assemble the class path information from our class loader chain
         ClassLoader loader = getClassLoader();
-        int n = 0;
+
+        if (delegate && loader != null) {
+            // Skip the webapp loader for now as delegation is enabled
+            loader = loader.getParent();
+        }
+
         while (loader != null) {
-            if (!(loader instanceof URLClassLoader)) {
-                String cp=getClasspath( loader );
-                if( cp==null ) {
-                    log.info( "Unknown loader " + loader + " " + 
loader.getClass());
-                } else {
-                    if (n > 0)
-                        classpath.append(File.pathSeparator);
-                    classpath.append(cp);
-                    n++;
-                }
+            if (!buildClassPath(servletContext, classpath, loader)) {
                 break;
-                //continue;
-            }
-            URL repositories[] =
-                ((URLClassLoader) loader).getURLs();
-            for (int i = 0; i < repositories.length; i++) {
-                String repository = repositories[i].toString();
-                if (repository.startsWith("file://"))
-                    repository = utf8Decode(repository.substring(7));
-                else if (repository.startsWith("file:"))
-                    repository = utf8Decode(repository.substring(5));
-                else if (repository.startsWith("jndi:"))
-                    repository =
-                        servletContext.getRealPath(repository.substring(5));
-                else
-                    continue;
-                if (repository == null)
-                    continue;
-                if (n > 0)
-                    classpath.append(File.pathSeparator);
-                classpath.append(repository);
-                n++;
             }
             loader = loader.getParent();
         }
 
+        if (delegate) {
+            // Delegation was enabled, go back and add the webapp paths
+            loader = getClassLoader();
+            if (loader != null) {
+                buildClassPath(servletContext, classpath, loader);
+            }
+        }
+
         this.classpath=classpath.toString();
 
         // Store the assembled class path as a servlet context attribute
@@ -1087,6 +1070,43 @@ public class WebappLoader extends Lifecy
 
     }
 
+
+    private boolean buildClassPath(ServletContext servletContext,
+            StringBuilder classpath, ClassLoader loader) {
+        if (loader instanceof URLClassLoader) {
+            URL repositories[] =
+                    ((URLClassLoader) loader).getURLs();
+                for (int i = 0; i < repositories.length; i++) {
+                    String repository = repositories[i].toString();
+                    if (repository.startsWith("file://"))
+                        repository = utf8Decode(repository.substring(7));
+                    else if (repository.startsWith("file:"))
+                        repository = utf8Decode(repository.substring(5));
+                    else if (repository.startsWith("jndi:"))
+                        repository =
+                            
servletContext.getRealPath(repository.substring(5));
+                    else
+                        continue;
+                    if (repository == null)
+                        continue;
+                    if (classpath.length() > 0)
+                        classpath.append(File.pathSeparator);
+                    classpath.append(repository);
+                }
+        } else {
+            String cp = getClasspath(loader);
+            if (cp == null) {
+                log.info( "Unknown loader " + loader + " " + 
loader.getClass());
+            } else {
+                if (classpath.length() > 0)
+                    classpath.append(File.pathSeparator);
+                classpath.append(cp);
+            }
+            return false;
+        }
+        return true;
+    }
+
     private String utf8Decode(String input) {
         String result = null;
         try {

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1451065&r1=1451064&r2=1451065&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Feb 28 00:53:29 2013
@@ -81,6 +81,10 @@
         Provide more consolidated servlet MBean data in the webapp MBean.
         (rjung)
       </update>
+      <fix>
+        <bug>54584</bug>: Take account of the delegate attribute when building
+        the web application class path to pass to the JSP compiler. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to