Index: common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java =================================================================== --- common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java (revision 35185) +++ common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java (working copy) @@ -80,6 +80,7 @@ import org.glassfish.api.deployment.InstrumentableClassLoader; import org.jvnet.hk2.component.PreDestroy; +import sun.net.www.ParseUtil; /** * Class loader used by the ejbs of an application or stand alone module. @@ -1347,15 +1348,26 @@ /** * @see java.net.URLStreamHandler#openConnection(java.net.URL) - * Should this method allow opening more than one connection? */ protected URLConnection openConnection(final URL u) throws IOException { - if (u != mURL) { // ref compare on purpose - // This should never happen - throw new IOException("Cannot open a foreign URL; this.url=" + mURL - + "; foreign.url=" + u); + String path = u.getPath(); + int separator = path.lastIndexOf('!'); + assert(separator != -1); // we deal with jar urls only + try { + URI jarFileURI = new URI(path.substring(0, separator)); + if (!jarFileURI.equals(mRes.file.toURI())) { + throw new IOException("Cannot open a foreign URL; this.url=" + mURL + + "; foreign.url=" + u); + } + String entryName = path.substring(separator+1); + if (entryName != null) { + assert (entryName.startsWith("/")); + entryName = entryName.substring(1); + } + return new InternalJarURLConnection(u, mRes, entryName); + } catch (URISyntaxException e) { + throw new IOException(e); } - return new InternalJarURLConnection(u, mRes, mName); } /**