What does “INFO: TLD skipped. URI is already defined” mean?

前端 未结 3 1259
日久生厌
日久生厌 2021-02-13 06:06

When running my JSF 2 application in eclipse I am getting several info logs that TLD was skipped because it\'s already defined as follows:



        
相关标签:
3条回答
  • 2021-02-13 07:05

    It means for example if you use Tomcat and Maven (or others servers) that you ship a JSTL library that is already found on the server and the server does complain.

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
    

    At the time you application is deployed (on Tomcat) then you get the error message:

    INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
    Mar 02, 2017 2:19:32 PM org.apache.catalina.startup.TaglibUriRule body
    

    The solution is to use the tag 'scope' and a value of 'provided' because JSTL is already shipped with Tomcat (it is only for your IDE):

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <scope>provided</scope>
        </dependency>
    

    Then the error will disappear.

    0 讨论(0)
  • 2021-02-13 07:06

    This means that you have duplicate TLD files in your webapp's runtime classpath. As TLDs are normally contained in the library JAR files, this in turn means that you have duplicate JAR files in your webapp's runtime classpath.

    Assuming that you haven't touched appserver's /lib folder nor the JDK's /lib folders, then those duplicates are in the /WEB-INF/lib folder of the WAR build. Cleanup it.

    0 讨论(0)
  • 2021-02-13 07:12

    Priority order of URIs required by spec is:

    J2EE platform taglibs - Tomcat doesn't provide these
    
    web.xml entries
    
    JARS in WEB-INF/lib & TLDs under WEB-INF (equal priority)
    
    Additional entries from the container
    

    Tomcat loads tld twice.

    1, when Tomcat starts up, it loads tld to find listeners in tld files.

    2, when first jsp file is compiled, it build a cache of tld pairs.

    1, load tld to find listeners in tld files

    When loading from web.xml, it puts taglib-uri from web.xml and uri from tld file into a set. When loading from WEB-INF or jar, the uri is from tld file.

    Tomcat needs to avoid duplicate tld listener adding, so it checks whether uri exists in the set. If uri already exists, it logs the messages you post and skip adding tld listener.

    2, build cache

    1) web.xml entries, the tag uri is got from web.xml

    2) scan tld files under WEB-INF, the tag uri is got from tld files

    3) scan jars, the tag uri is got from tld files.

    If uri aready exists, the entry will be ignored.

    0 讨论(0)
提交回复
热议问题