Author: manik.surtani(a)jboss.com
Date: 2008-01-01 20:55:51 -0500 (Tue, 01 Jan 2008)
New Revision: 4933
Modified:
core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java
Log:
Fixed classpath scanning within jar files
Modified: core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java 2008-01-02
00:32:16 UTC (rev 4932)
+++ core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java 2008-01-02
01:55:51 UTC (rev 4933)
@@ -2,6 +2,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.config.ConfigurationException;
import java.io.File;
import java.io.IOException;
@@ -70,11 +71,11 @@
}
catch (IOException ioe)
{
- log.warn("could not read entries", ioe);
+ log.fatal("could not read entries", ioe);
}
catch (ClassNotFoundException e)
{
- log.warn("Unable to load class", e);
+ log.fatal("Unable to load class", e);
}
return classes;
@@ -83,17 +84,19 @@
private URL getURLPathFromClassLoader() throws MalformedURLException
{
URL u2 = classLoader.findResource("org/jboss/cache/Version.class");
+ String u2String = u2.toString();
+ boolean isJar = u2String.startsWith("jar:") &&
u2String.contains(".jar!/");
+
for (URL u : classLoader.getURLs())
{
- String urlString = u.toString().replaceAll("\\/\\.\\/",
"/");
- if (u2.toString().startsWith(urlString))
- {
- return new URL(urlString);
- }
+ String originalUrlString = u.toString().replaceAll("\\/\\.\\/",
"/");
+ String urlString = originalUrlString;
+ if (isJar) urlString = "jar:" + urlString + "!/";
+ if (u2String.startsWith(urlString)) return new URL(originalUrlString);
}
- return null;
+ throw new ConfigurationException("Unable to find core JBoss Cache classes on
classpath!");
}
Show replies by date