Index: src/main/java/org/springframework/osgi/io/OsgiBundleResourcePatternResolver.java =================================================================== --- src/main/java/org/springframework/osgi/io/OsgiBundleResourcePatternResolver.java (revision 2435) +++ src/main/java/org/springframework/osgi/io/OsgiBundleResourcePatternResolver.java (working copy) @@ -192,6 +192,7 @@ } // add a non-existing resource, if none was found and no pattern was specified + @Override public Resource[] getResources(final String locationPattern) throws IOException { Resource[] resources = findResources(locationPattern); @@ -241,6 +242,7 @@ if (System.getSecurityManager() != null) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { for (int i = 0; i < importedBundles.length; i++) { final ImportedBundle importedBundle = importedBundles[i]; @@ -454,6 +456,8 @@ JarInputStream jis = new JarInputStream(url.openStream()); Set result = new LinkedHashSet(8); + boolean patternWithFolderSlash = pattern.startsWith(FOLDER_SEPARATOR); + // parse the jar and do pattern matching try { while (jis.available() > 0) { @@ -462,9 +466,15 @@ if (jarEntry != null) { String entryPath = jarEntry.getName(); - // strip leading "/" if it does exist + // check if leading "/" is needed or not (it depends how the jar was created) if (entryPath.startsWith(FOLDER_SEPARATOR)) { - entryPath = entryPath.substring(FOLDER_SEPARATOR.length()); + if (!patternWithFolderSlash) { + entryPath = entryPath.substring(FOLDER_SEPARATOR.length()); + } + } else { + if (patternWithFolderSlash) { + entryPath = FOLDER_SEPARATOR.concat(entryPath); + } } if (getPathMatcher().match(pattern, entryPath)) { result.add(entryPath); @@ -590,6 +600,7 @@ * expensive operation as there is no caching (due to the framework dynamic * nature). */ + @Override protected boolean isJarResource(Resource resource) throws IOException { if (resource instanceof OsgiBundleResource) { // check the resource type