jodd-core/src/main/java/jodd/util/ClassLoaderUtil.java
public static URL getResourceUrl(String resourceName, final ClassLoader classLoader) {

		if (resourceName.startsWith("/")) {
			resourceName = resourceName.substring(1);
		}
		
		URL resourceUrl;

		// try #1 - using provided class loader
		if (classLoader != null) {
			resourceUrl = classLoader.getResource(resourceName);
			if (resourceUrl != null) {
				return resourceUrl;
			}
		}

		// try #2 - using thread class loader
		ClassLoader currentThreadClassLoader = Thread.currentThread().getContextClassLoader();
		if ((currentThreadClassLoader != null) && (currentThreadClassLoader != classLoader)) {
			resourceUrl = currentThreadClassLoader.getResource(resourceName);
			if (resourceUrl != null) {
				return resourceUrl;
			}
		}

		// try #3 - using caller classloader, similar as Class.forName()
		Class callerClass = ClassUtil.getCallerClass(2);
		ClassLoader callerClassLoader = callerClass.getClassLoader();

		if ((callerClassLoader != classLoader) && (callerClassLoader != currentThreadClassLoader)) {
			resourceUrl = callerClassLoader.getResource(resourceName);
			if (resourceUrl != null) {
				return resourceUrl;
			}
		}

		return null;
	}
public static URL getResourceUrl(String resourceName, final ClassLoader classLoader) {

		if (resourceName.startsWith("/")) {
			resourceName = resourceName.substring(1);
		}
		
		URL resourceUrl;

		// try #1 - using provided class loader
		if (classLoader != null) {
			resourceUrl = classLoader.getResource(resourceName);
			if (resourceUrl != null) {
				return resourceUrl;
			}
		}

		// try #2 - using thread class loader
		ClassLoader currentThreadClassLoader = Thread.currentThread().getContextClassLoader();
		if ((currentThreadClassLoader != null) && (currentThreadClassLoader != classLoader)) {
			resourceUrl = currentThreadClassLoader.getResource(resourceName);
			if (resourceUrl != null) {
				return resourceUrl;
			}
		}

		// try #3 - using caller classloader, similar as Class.forName()
		Class callerClass = ClassUtil.getCallerClass(2);
		ClassLoader callerClassLoader = callerClass.getClassLoader();

		if ((callerClassLoader != classLoader) && (callerClassLoader != currentThreadClassLoader)) {
			resourceUrl = callerClassLoader.getResource(resourceName);
			if (resourceUrl != null) {
				return resourceUrl;
			}
		}

		return null;
	}
public static URL getResourceUrl ( String resourceName , final ClassLoader classLoader ) { if ( resourceName . startsWith ( "/" ) ) { resourceName = resourceName . substring ( 1 ) ; } URL resourceUrl ; // try #1 - using provided class loader if ( classLoader != null ) { resourceUrl = classLoader . getResource ( resourceName ) ; if ( resourceUrl != null ) { return resourceUrl ; } } // try #2 - using thread class loader ClassLoader currentThreadClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( ( currentThreadClassLoader != null ) && ( currentThreadClassLoader != classLoader ) ) { resourceUrl = currentThreadClassLoader . getResource ( resourceName ) ; if ( resourceUrl != null ) { return resourceUrl ; } } // try #3 - using caller classloader, similar as Class.forName() Class callerClass = ClassUtil . getCallerClass ( 2 ) ; ClassLoader callerClassLoader = callerClass . getClassLoader ( ) ; if ( ( callerClassLoader != classLoader ) && ( callerClassLoader != currentThreadClassLoader ) ) { resourceUrl = callerClassLoader . getResource ( resourceName ) ; if ( resourceUrl != null ) { return resourceUrl ; } } return null ; }
Retrieves given resource as URL. Resource is always absolute and may
starts with a slash character.
<p>
Resource will be loaded using class loaders in the following order:
<ul>
<li>{@link Thread#getContextClassLoader() Thread.currentThread().getContextClassLoader()}</li>
<li>{@link Class#getClassLoader() ClassLoaderUtil.class.getClassLoader()}</li>
<li>if <code>callingClass</code> is provided: {@link Class#getClassLoader() callingClass.getClassLoader()}</li>
</ul>
Retrieves given resource as URL . Resource is always absolute and may starts with a slash character . <p > Resource will be loaded using class loaders in the following order : <ul > <li > {