kamranzafar / JCL

Jar Class Loader, a configurable and dynamic custom classloader designed to create, manage and manipulate isolated Java classloaders in IoC frameworks and web applications.
http://kamranzafar.github.com/
579 stars 161 forks source link

getResource() fails for resources that are not within a jar #41

Closed matthoffman closed 8 years ago

matthoffman commented 8 years ago

Say you have a directory structure like this:

    someDirectory/
           someFile

You can have jars or classes inside someDirectory too, it doesn't matter. If you call:

    jcl.add("someDirectory")

And then try to call jcl.getResource("someFile"), JCL throws an exception:

    org.xeustechnologies.jcl.exception.JclException: java.net.MalformedURLException: no protocol: /home/whoever/file/path/someDirectory/someFilesomeFile
    at org.xeustechnologies.jcl.JarResources.getResourceURL(JarResources.java:74)
    at org.xeustechnologies.jcl.JarClassLoader$LocalLoader.findResource(JarClassLoader.java:285)
    at org.xeustechnologies.jcl.AbstractClassLoader.getResource(AbstractClassLoader.java:150)

Note that the filename (someFile) is actually repeated twice in the returned filename. I'll submit a PR shortly.

kamranzafar commented 8 years ago

Fix available in version 2.7