Index: src/test/java/org/apache/servicemix/xbean/ClassLoaderXmlPreprocessorTest.java
===================================================================
--- src/test/java/org/apache/servicemix/xbean/ClassLoaderXmlPreprocessorTest.java	(revision 0)
+++ src/test/java/org/apache/servicemix/xbean/ClassLoaderXmlPreprocessorTest.java	(revision 0)
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.xbean;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Unit test for the ClassLoaderXmlPreprocessor, mainly focus on the getResource
+ * URL supports
+ * 
+ * @author jbonofre
+ */
+public class ClassLoaderXmlPreprocessorTest extends TestCase {
+
+    // logging facility
+    private static final transient Log LOG = LogFactory
+            .getLog(ClassLoaderXmlPreprocessorTest.class);
+
+    public void testJarResources() throws Exception {
+        LOG.debug("Create a ClassLoaderXmlPreprocessor with . as root");
+        ClassLoaderXmlPreprocessor classloader = new ClassLoaderXmlPreprocessor(
+                new File("."));
+
+        LOG.debug("Get the /tmp resource URL");
+        URL dirResource = classloader.getResource("src/test/resources");
+        LOG.info("Directory relative resource : " + dirResource.toString());
+        URL fileResource = classloader.getResource("file:./src/test/resources");
+        LOG.info("File absolute resource : " + fileResource.toString());
+        URL jarResource = classloader.getResource("jar:file:./src/test/resources/test.ear!/test");
+        LOG.info("Inside jar file resource : " + jarResource.toString());
+        URL jarRegexpResource = classloader.getResource("jar:file:./src/test/resources/test.ear!/te(.*)");
+        LOG.info("Inside jar regexp file resource : " + jarRegexpResource.toString());
+        assertEquals(new URL("jar:file:./src/test/resources/test.ear!/test"), jarRegexpResource);
+    }
+
+}
Index: src/test/resources/test.ear
===================================================================
--- src/test/resources/test.ear	(revision 0)
+++ src/test/resources/test.ear	(revision 0)
@@ -0,0 +1,2 @@
+PK   ]ZM:            	  META-INF/þÊ   PK           PK   ]ZM:               META-INF/MANIFEST.MFóMÌËLK-.Ñ+K-*ÎÌÏ³R0Ô3àår.JM,IMÑuª	˜êÄš(h—æ)øf&åW—¤æ+xæ%ëiòrñr PK-ïµ,G   G   PK   UZM:               testóJ,rÍ+)ªTI-.á PKV°,0      PK    ]ZM:           	                META-INF/þÊ  PK    ]ZM:-ïµ,G   G                =   META-INF/MANIFEST.MFPK    UZM:V°,0                   Æ   testPK      ¯       
\ No newline at end of file
Index: src/main/java/org/apache/servicemix/xbean/ClassLoaderXmlPreprocessor.java
===================================================================
--- src/main/java/org/apache/servicemix/xbean/ClassLoaderXmlPreprocessor.java	(revision 744053)
+++ src/main/java/org/apache/servicemix/xbean/ClassLoaderXmlPreprocessor.java	(working copy)
@@ -22,8 +22,11 @@
 import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 
 import javax.xml.parsers.DocumentBuilder;
 
@@ -39,6 +42,7 @@
 import org.springframework.beans.FatalBeanException;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 
+
 /**
  * An advanced xml preprocessor that will create a default classloader for the SU if none
  * is configured.
@@ -90,19 +94,87 @@
         Thread.currentThread().setContextClassLoader(classLoader);
     }
 
+    /**
+     * <p>
+     * Get the URL for a classpath location. This method supports standard relative file location,
+     * <code>file:</code> URL location, <code>jar:</code> URL location with regexp on the entries.
+     * </p>
+     * 
+     * @param location the location where to get the URL
+     * @return the URL matching the location
+     */
     protected URL getResource(String location) {
-        URI uri = root.toURI().resolve(location);
-        File file = new File(uri);
+        if (location.startsWith("jar:file:")) {
+            try {
+                return this.getJarResource(location);
+            } catch (Exception e) {
+                throw new IllegalArgumentException("Can't get the Jar resource " + location, e);
+            }
+        } else if (location.startsWith("file:")) {
+            try {
+                return new URL(location);
+            } catch (MalformedURLException e) {
+                throw new IllegalArgumentException("Malformed file URL resource " + location, e);
+            }
+        } else {
+            URI uri = root.toURI().resolve(location);
+            File file = new File(uri);
 
-        if (!file.canRead()) {
-            return null;
-        }
+            if (!file.canRead()) {
+                return null;
+            }
 
-        try {
-            return file.toURL();
-        } catch (MalformedURLException e) {
-            throw new IllegalArgumentException("Malformed resource " + uri);
+            try {
+                return file.toURL();
+            } catch (MalformedURLException e) {
+                throw new IllegalArgumentException("Malformed resource " + uri);
+            }
+        }
+    }
+    
+    /**
+     * Manager Jar location including regexp on the Jar entries.
+     * A Jar location looks like jar:/path/to/my.ear!/entry.jar or
+     * jar:/path/to/my.ear!/ent*.jar
+     * 
+     * @param location the Jar location
+     * @return the Jar URL
+     * @throws Exception in case of error while exploring the Jar location
+     */
+    protected URL getJarResource(String location) throws Exception {
+        // parse the jar URI
+        StringBuffer locationBuffer = new StringBuffer(location);
+        if (locationBuffer.length() < 9) {
+            throw new IllegalArgumentException("The Jar location is not valid. It must contain at least the jar:file: protocol.");
+        }
+        // get the separator position
+        int separatorPosition = locationBuffer.indexOf("!/");
+        if (separatorPosition == -1) {
+            throw new IllegalArgumentException("The Jar location is not valid. Separator !/ not found");
+        }
+        // get the jar file URI
+        String fileName = locationBuffer.substring(9, separatorPosition);
+        // get the jar entry
+        String entryName = locationBuffer.substring(separatorPosition + 2, locationBuffer.length());
+        if (fileName == null || fileName.trim().length() < 1
+                || entryName == null || entryName.trim().length() < 1) {
+            throw new IllegalArgumentException("The Jar location is not valid. Jar file or entry is empty");
+        }
+        // read the jar file (as a zip file)
+        ZipFile zipFile = new ZipFile(fileName);
+        // get the zip file entries
+        Enumeration entries = zipFile.entries();
+        String found = null;
+        while (entries.hasMoreElements()) {
+            ZipEntry entry = (ZipEntry)entries.nextElement();
+            if (entry.getName().matches(entryName)) {
+                found = entry.getName();
+                break;
+            }
         }
+        // construct the URL
+        String url = "jar:file:" + fileName + "!/" + found;
+        return new URL(url);
     }
     
     protected URL[] getDefaultLocations() {
