tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Boynes <jboy...@apache.org>
Subject Re: TLD files packaged in JAR required to be under META-INF/resources?
Date Wed, 30 May 2018 15:59:48 GMT
> On May 30, 2018, at 3:13 AM, Tomas Hofman <thofman@redhat.com> wrote:
> 
> Hello,
> 
> I run into something that looks like non spec-conforming behavior and would like to check
with you if it's really a bug or I'm having incorrect expectations.
> 
> I have TLD located in JAR under META-INF/tlds/hi.tld. The JAR also contains web-fragment.xml
with taglib mapping like this:
> 
>  <web-fragment ...>
>    <jsp-config>
>        <taglib>
>            <taglib-uri>/HiTag</taglib-uri>
>            <taglib-location>/tlds/hi.tld</taglib-location>
>        </taglib>
>    </jsp-config>
>  </web-fragment>
> 
> This JAR is loaded in a WAR, that contains JSP with following directive:
> 
>  <%@ taglib uri="/HiTag" prefix="say"%>
> 
> During deployment in apache-tomcat-9.0.8 I see this warning:
> 
> 30-May-2018 10:38:42.240 WARNING [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
org.apache.jasper.servlet.TldScanner.scanJspConfig Failed to process TLD with path [/tlds/hi.tld]
and URI [/HiTag]. The specified path does not exist.
> 
> and the jsp compilation fails.
> 
> When I move the TLD under META-INF/resources, then it starts to work.
> When I use implicit mapping by defining <uri> element in hi.tld instead of explicit
mapping in web-fragment.xml, that works too.
> 
> The JSP spec says that TLDs must be in META-INF/ or subdirectories:
> 
> [quote]
> JSP 7.3.1
> 
> When deployed inside a JAR file, the tag library descriptor files must be in the META-INF
directory, or a subdirectory of it.
> [/quote]
> 
> I think it's caused by this line in TldScanner.java:
> 
> https://github.com/apache/tomcat/blob/TOMCAT_8_0_0_RC10/java/org/apache/jasper/servlet/TldScanner.java#L177
> 
> where ServletContext#getResource() would naturally see only files under META-INF/resources/
dir.
> 
> Thanks for any opinions!

This may be better addressed to user@t.a.o as this really relates to the Jasper JSP engine
rather than the taglib itself. Having said that, here’s how I read the spec.

JSP 7.3.3 talks about a “taglib map” using elements in the deployment descriptor per your
example. Per JSP 7.3.2 the URI is mapped to a _context relative path_ interpreted relative
to the root of the web application. Resources contained in a web fragment jar are located
in its /META-INF/resources directory. Tomcat/Jasper are synthesizing the effective web application
from the resources in the fragments, then resolving the URI in the taglib map against that
merged application. I think that’s a correct interpretation of the spec.

JSP 7.3.1 refers to implicit map entries found by scanning the web application’s jars from
WEB-INF/lib

--
Jeremy


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@tomcat.apache.org
For additional commands, e-mail: taglibs-user-help@tomcat.apache.org


Mime
View raw message