[jboss-jira] [JBoss JIRA] (WFLY-10411) TLDs under META-INF/resources inside the web-fragment jar is not loaded

Tomas Hofman (JIRA) issues at jboss.org
Tue May 29 11:52:00 EDT 2018


    [ https://issues.jboss.org/browse/WFLY-10411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13583759#comment-13583759 ] 

Tomas Hofman commented on WFLY-10411:
-------------------------------------

I think the reproducer doesn't conform to spec at several places.


1) Incorrect <taglib-location>

The web-fragment.xml in the reproducer jar contains:
{code}
        <taglib>
            <taglib-uri>/HiTag</taglib-uri>
            <taglib-location>/WEB-INF/tlds/hi.tld</taglib-location>
        </taglib>
{code}

but the tld file in the jar is placed in {{META-INF/resources/WEB-INF/tlds/hi.tld}}. I.e. {{<taglib-location>}} omits "resources" directory, hence the first error "WFLYUT0074: Could not find TLD".

Quote from JSP 2.1 spec:
{quote}
JSP.7.3.1 Identifying Tag Library Descriptors

When deployed inside a JAR file, the tag library descriptor files must be in the
META-INF directory, or a subdirectory of it.

When deployed directly into a web application, the tag library descriptor
files must always be in the WEB-INF directory, or some subdirectory of it.
{quote}
>From which I understand that {{META-INF}} should be taken as root, not {{META-INF/resources}}.

It would be easy to add {{META-INF/resources}} as another root in {{TldParsingDeploymentProcessor}} if we wanted to allow this to have equivalent behavior with Tomcat.

Fixing the uri in web-fragment.xml, one of the two JSPs starts to work. Taglib directive in it is:
{code}<%@ taglib uri="/HiTag" prefix="say"%>{code}


2) Incorrect taglib uri in index.jsp taglib directive

Taglib directive in index.jsp is
{code}<%@ taglib uri="/WEB-INF/tlds/hi.tld" prefix="say"%>{code}
i.e. the tld is referenced directly by it's relative location. This would work if the taglib was located directly in the WAR. The real relative location of the tld in jar from the war root is different: "/WEB-INF/lib/simple-taglib-1.0.jar/META-INF/resources/WEB-INF/tlds/hi.tld".

Fixing the uri to the latter however doesn't work either, and I'm not sure if it should.

>From the spec, mainly sections from 7.3.2 to 7.3.6, it's not clear to me if taglib uri can be path into nested JAR or not.

> TLDs under META-INF/resources inside the web-fragment jar is not loaded
> -----------------------------------------------------------------------
>
>                 Key: WFLY-10411
>                 URL: https://issues.jboss.org/browse/WFLY-10411
>             Project: WildFly
>          Issue Type: Bug
>          Components: Web (Undertow)
>    Affects Versions: 13.0.0.Beta1
>            Reporter: Masafumi Miura
>            Assignee: Stuart Douglas
>         Attachments: jsp-taglib-jar-in-war.zip
>
>
> TLDs under META-INF/resources inside the web-fragment jar is not loaded.
> {code:title=directory structure of the web-fragment jar}
> taglib-jar
> |-- META-INF
> |   |-- resources
> |   |   `-- WEB-INF
> |   |       `-- tlds
> |   |           `-- hi.tld
> |   `-- web-fragment.xml
> `-- simple
>     `-- HiTag.class
> {code}
> {code:title=web-fragment.xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <web-fragment id="WebFragment_ID"
>     version="3.0"
>     xmlns="http://java.sun.com/xml/ns/javaee"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd">
>     ...(snip)...
>     <jsp-config>
>         <taglib>
>             <taglib-uri>/HiTag</taglib-uri>
>             <taglib-location>/WEB-INF/tlds/hi.tld</taglib-location>
>         </taglib>
>     </jsp-config>
> </web-fragment>
> {code}
> The following ERROR is thrown at the deployment:
> {code}
> ERROR [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0074: Could not find TLD /WEB-INF/tlds/hi.tld
> {code}
> JSP returns "500 Internal Server Error" and Jastow throws the following ERROR when accessing the JSP which has {{<%@ taglib uri="/HiTag" prefix="say"%>}} or {{<%@ taglib uri="/WEB-INF/tlds/hi.tld" prefix="say"%>}}:
> {code}
> ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /taglib-jar-in-war/hi.jsp: org.apache.jasper.JasperException: JBWEB004036: File "/HiTag" not found
> 	at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:57)
> 	at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:278)
> 	at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:75)
> 	at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:171)
> 	at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:412)
> 	at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
> 	at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1459)
> 	at org.apache.jasper.compiler.Parser.parse(Parser.java:143)
> 	at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:223)
> 	at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
> 	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:200)
> 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
> 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
> 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
> 	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:652)
> 	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
> 	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
> 	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
> 	...(snip)...
> {code}
> {code}
> ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /taglib-jar-in-war/index.jsp: org.apache.jasper.JasperException: JBWEB004036: File "/WEB-INF/tlds/hi.tld" not found
> 	at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:57)
> 	at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:278)
> 	at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:75)
> 	at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:171)
> 	at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:412)
> 	at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
> 	at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1459)
> 	at org.apache.jasper.compiler.Parser.parse(Parser.java:143)
> 	at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:223)
> 	at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
> 	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:200)
> 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
> 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
> 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
> 	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:652)
> 	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
> 	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
> 	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
> 	...(snip)...
> {code}
> Note that the same war file can be deployed and the JSPs works on Tomcat 8.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list