Skip to content

Resource loading fails for embedded webserver war deploy #2

@angshu

Description

@angshu

Hi, We deploy our application as war with embedded Tomcat. During the initialization mutagen.initialize("org/example/cassandra/migrations") fails to find the resources within the "org/example/cassandra/migrations" which is available under WEB-INF/classes/. The reason, I believe, is because of the URI parsing logic and reading in ResourceScanner. While running, ResourceScanner.getResources() will identify the URL of the migrations path as "jar:file:/var/lib/exmaple.war!/WEB-INF/classes!/org/example/cassandra/migrations". Note the "!" after "classes". ResourceScanner.getResources(URI, Pattern) method parses the URI string by the first "!" character and tries to match it ResourceScanner.getResourcesFromJarFile() against a entry name. The entry names will come up as "/WEB-INF/classes/org/example/cassandra/migrations" for a CQL file within that directory and fails against comparison with rest of the split string "/WEB-INF/classes!/org/example/cassandra/migrations", eventually resulting in exception "Could not find resources on path org/example/cassandra/migrations ..".

Tentative solution

  • parse the string and replace "!" char, so that "WEB-INF/classes!/.." becomes "WEB-INF/classes/..", so that "resourcePathPrefix" in ResourceScanner.getResourcesFromJarFile() works during comparison.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions