diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java index 13770b2f15d..50704352c5f 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java @@ -279,12 +279,20 @@ public class WebAppClassLoader extends URLClassLoader StringTokenizer tokenizer= new StringTokenizer(classPath, ",;"); while (tokenizer.hasMoreTokens()) { - Resource resource= _context.newResource(tokenizer.nextToken().trim()); + String token = tokenizer.nextToken().trim(); + Resource resource= _context.newResource(token); if (LOG.isDebugEnabled()) LOG.debug("Path resource=" + resource); - // Add the resource - if (resource.isDirectory() && resource instanceof ResourceCollection) + if(token.endsWith("*")) + { + if(token.length() > 1) + { + token = token.substring(0, token.length() - 1); + resource= _context.newResource(token); + addJars(resource); + } + } else if (resource.isDirectory() && resource instanceof ResourceCollection) addClassPath(resource); else { diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java index 2dd052775ce..ea56302f0f0 100644 --- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java +++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java @@ -65,6 +65,7 @@ public class WebAppClassLoaderTest _context = new WebAppContext(); _context.setBaseResource(webapp); _context.setContextPath("/test"); + _context.setExtraClasspath("src/test/resources/ext/*"); _loader = new WebAppClassLoader(_context); _loader.addJars(webapp.addPath("WEB-INF/lib")); @@ -105,6 +106,10 @@ public class WebAppClassLoaderTest assertCanLoadClass("org.acme.webapp.ClassInJarB"); assertCanLoadClass("org.acme.other.ClassInClassesC"); + assertCanLoadClass("org.acme.extone.Main"); + assertCanLoadClass("org.acme.exttwo.Main"); + assertCantLoadClass("org.acme.extthree.Main"); + assertCantLoadClass("org.eclipse.jetty.webapp.Configuration"); Class clazzA = _loader.loadClass("org.acme.webapp.ClassInJarA"); @@ -119,6 +124,10 @@ public class WebAppClassLoaderTest assertCanLoadClass("org.acme.webapp.ClassInJarB"); assertCanLoadClass("org.acme.other.ClassInClassesC"); + assertCanLoadClass("org.acme.extone.Main"); + assertCanLoadClass("org.acme.exttwo.Main"); + assertCantLoadClass("org.acme.extthree.Main"); + assertCantLoadClass("org.eclipse.jetty.webapp.Configuration"); Class clazzA = _loader.loadClass("org.acme.webapp.ClassInJarA"); diff --git a/jetty-webapp/src/test/resources/ext/org-acme-ext-one.jar b/jetty-webapp/src/test/resources/ext/org-acme-ext-one.jar new file mode 100644 index 00000000000..e52c47a83d8 Binary files /dev/null and b/jetty-webapp/src/test/resources/ext/org-acme-ext-one.jar differ diff --git a/jetty-webapp/src/test/resources/ext/org-acme-ext-two.jar b/jetty-webapp/src/test/resources/ext/org-acme-ext-two.jar new file mode 100644 index 00000000000..f46fb20ad35 Binary files /dev/null and b/jetty-webapp/src/test/resources/ext/org-acme-ext-two.jar differ diff --git a/jetty-webapp/src/test/resources/ext/sub/org-acme-ext-three.jar b/jetty-webapp/src/test/resources/ext/sub/org-acme-ext-three.jar new file mode 100644 index 00000000000..11a24abab72 Binary files /dev/null and b/jetty-webapp/src/test/resources/ext/sub/org-acme-ext-three.jar differ