XSD validation error: TagLib tag in web.xml is not found
Asked Answered
M

3

5

I show the error in detail as follows.

cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'.

One of {

  • "http://java.sun.com/xml/ns/javaee":description,
  • "http://java.sun.com/xml/ns/javaee":display-name,
  • "http://java.sun.com/xml/ns/javaee":icon,
  • "http://java.sun.com/xml/ns/javaee":distributable,
  • "http://java.sun.com/xml/ns/javaee":context-param,
  • "http://java.sun.com/xml/ns/javaee":filter,
  • "http://java.sun.com/xml/ns/javaee":filter-mapping,
  • "http://java.sun.com/xml/ns/javaee":listener,
  • "http://java.sun.com/xml/ns/javaee":servlet,
  • "http://java.sun.com/xml/ns/javaee":servlet-mapping,
  • "http://java.sun.com/xml/ns/javaee":session-config,
  • "http://java.sun.com/xml/ns/javaee":mime-mapping,
  • "http://java.sun.com/xml/ns/javaee":welcome-file-list,
  • "http://java.sun.com/xml/ns/javaee":error-page,
  • "http://java.sun.com/xml/ns/javaee":jsp-config,
  • "http://java.sun.com/xml/ns/javaee":security-constraint,
  • "http://java.sun.com/xml/ns/javaee":login-config,
  • "http://java.sun.com/xml/ns/javaee":security-role,
  • "http://java.sun.com/xml/ns/javaee":env-entry,
  • "http://java.sun.com/xml/ns/javaee":ejb-ref,
  • "http://java.sun.com/xml/ns/javaee":ejb-local-ref,
  • "http://java.sun.com/xml/ns/javaee":service-ref,
  • "http://java.sun.com/xml/ns/javaee":resource-ref,
  • "http://java.sun.com/xml/ns/javaee":resource-env-ref,
  • "http://java.sun.com/xml/ns/javaee":message-destination-ref,
  • "http://java.sun.com/xml/ns/javaee":persistence-context-ref,
  • "http://java.sun.com/xml/ns/javaee":persistence-unit-ref,
  • "http://java.sun.com/xml/ns/javaee":post-construct,
  • "http://java.sun.com/xml/ns/javaee":pre-destroy,
  • "http://java.sun.com/xml/ns/javaee":message-destination,
  • "http://java.sun.com/xml/ns/javaee":locale-encoding-mapping-list

}

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  
    <display-name>Hello World Struts Application</display-name>

    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>3</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>3</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <taglib>
        <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
    </taglib>

</web-app>
Moonshine answered 11/8, 2011 at 7:17 Comment(3)
Did you check the dtd or xsd for the order that elements have to be in? I also struggled with this before realizing that in many schemas the order of elements is not arbitrary (although they are quite independent).Seaborne
@beny: I added web.xml code.Please do me the favour for me.Moonshine
Possible duplicate of #3775764Prenomen
A
3

Taglib is no longer required to be declared in web.xml , please read http://wiki.metawerx.net/wiki/RemovingTaglibFromWeb.xml

You are using Servlet 2.5, so the instructions should work for you

Aguirre answered 11/8, 2011 at 8:26 Comment(0)
M
21

Modify your web.xml so that all the taglib tags are contained in jsp-config tag. i.e:

 <jsp-config>
     <taglib>
         <taglib-uri></taglib-uri>
         <taglib-location></taglib-location>
     </taglib>
 </jsp-config>
Merrell answered 11/8, 2011 at 9:1 Comment(1)
before taglib, there is a tag <jsp-config>. I am trying but am not able to write it in my answer. It is showing nothing for that.Merrell
A
3

Taglib is no longer required to be declared in web.xml , please read http://wiki.metawerx.net/wiki/RemovingTaglibFromWeb.xml

You are using Servlet 2.5, so the instructions should work for you

Aguirre answered 11/8, 2011 at 8:26 Comment(0)
D
0

//within: web.xml file

http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">

<jsp-config>
    <taglib>
        <taglib-uri>/taglib</taglib-uri>
        <taglib-location>/WEB-INF/tlds/taglib.tld</taglib-location>
    </taglib>
</jsp-config>

Dyarchy answered 19/8, 2016 at 5:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.