jspjsp-tagstaglibtag-library-descriptor

Invalid tld file, but its the filename


I'm creating a custom taglib under SpringBoot. My taglib tag is:

<%@taglib prefix="ttl" uri="/WEB-INF/tags/resourceBundle.tld" %>

I created a TLD file according to the many sources available and placed it in /WEB-INF/tags/resourceBundle.tld, here is the part with the uri tag

<taglib>
    <uri>/WEB-INF/tags/resourceBundle.tld</uri>
    ...

but I get this error message when I reference the tag library:

org.apache.jasper.JasperException: Invalid tld file: [/WEB-INF/tags/resourceBundle.tld], see JSP specification section 7.3.1 for more details

however, I don't believe it ever gets read as it is determined to be invalid in TagLibraryInfoImpl::generateTldResourcePath()@281:

    if (uri.endsWith(".jar")) {
       // snip
    } else if (uri.startsWith("/WEB-INF/lib/") || uri.startsWith("/WEB-INF/classes/") ||
            (uri.startsWith("/WEB-INF/tags/") && uri.endsWith(".tld")&& !uri.endsWith("implicit.tld"))) {
        err.jspError("jsp.error.tld.invalid_tld_file", uri);
    }

The code ends up at the last err.jspError line:

        err.jspError("jsp.error.tld.invalid_tld_file", uri);

Basically, if the URI starts with "/WEB-INF/tags" (as many sources say is mandatory) and ends with ".tld", but not "implicit.tld", then the tld file is "invalid" - this conclusion is reached without even opening the file.

I have changed the <%@taglib%> uri to reference a non-existent file and get the same error message from the same path through the code (above).

I've read numerous articles on the subject and reviewed an old project on which I used a custom taglib (but it used ANT and Spring, I'm using Maven and SpringBoot), I cannot figure out how get my tag library recognized.

Can somebody tell me what I am doing wrong?


Solution

  • The JSP 2.1 specification states that:

    TLD files should not be placed in /WEB-INF/classes or /WEB-INF/lib, and must not be placed inside /WEB-INF/tags or a subdirectory of it, unless named implicit.tld.

    I suggest using another directory.