Skip to content

ClassLoader getResource(...) does not check WEB-INF/lib JARs #59

@andymc12

Description

@andymc12
Issue Overview

When my test app calls getResource("META-INF/someResource.txt") on the web app's classloader, it fails to find anything - even though the file exists in a JAR file in the WEB-INF/lib directory. When I search for the same resource using getResources, the returned set of URLs includes the URL to the resource in the WEB-INF/lib JAR file.

Expected Behaviour

The getResource method should search JAR files in the WEB-INF/lib directory after searching the WEB-INF/classes directory.

Current Behaviour

The getResource method only searches the WEB-INF/classes directory.

Steps To Reproduce
  1. Deploy a WAR file that contains a WEB-INF/lib JAR file that contains a text files called META-INF/someResource.txt.
  2. From another test case, obtain the WAR's classloader and invoke loader.getResources("META-INF/someResource.txt") - this will return an Enumeration with a URL to the resource - all good so far.
  3. From another test case, obtain the WAR's classloader and invoke loader.getResource("META-INF/someResource.txt") - this will fail.
Additional Information

I think the problem is here:

Unlike the getResources method, this method just adjusts the name for searching the WEB-INF/classes directory and then delegates to the super class. I think it should follow the same pattern as getResources and search the JAR files in the WEB-INF/lib directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions