0
votes

What these xml validation results actually stand for?

Referenced entity at "nbres:/org/netbeans/modules/j2ee/ddloaders/catalog/resources/datatypes.dtd". cvc-complex-type.2.4.a: Invalid content was found starting with element 'filter-name'. 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":servlet-name}' is expected. [48] The element type "servlet" must be terminated by the matching end-tag "". [50] XML validation finished.

I'm not too familiar with these!

My file:

<?xml version="1.0" encoding="UTF-8"?> 
 <web-app version="2.5" 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-app_2_5.xsd">

  <display-name>KeyCard</display-name>
- <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml
  /WEB-INF/tilesViewContext.xml
  /WEB-INF/ldap-config.xml
   /WEB-INF/security-config.xml
    /WEB-INF/idm-config.xml
  </param-value>
  </context-param>

 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
 <filter>
  <filter-name>charsetFilter</filter-name>
  <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
 <init-param>
  <param-name>encoding</param-name>
  <param-value>UTF-8</param-value>
  </init-param>
 <init-param>
  <param-name>forceEncoding</param-name>
  <param-value>true</param-value>
  </init-param>
  </filter>

  <filter>
  <filter-name>springSecurityFilterChain</filter-name>
  <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  </filter>



 <filter-mapping>
  <filter-name>charsetFilter</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
 <servlet>

 <filter>
  <filter-name>springSecurityFilterChain</filter-name>
  <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  </filter>

<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  </listener>

 <listener>
  <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
  </listener>

 <filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>


  <servlet-name>KeyCard</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
  </servlet>
 <servlet-mapping>
  <servlet-name>KeyCard</servlet-name>
  <url-pattern>*.html</url-pattern>
  </servlet-mapping>


 <session-config>
  <session-timeout>120</session-timeout>
  </session-config>
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  </web-app>
2
Please read your question and see if you can understand it - I doubt anyone else will - you need to format the xml as codemmmmmm

2 Answers

0
votes

Did you hand-code this xml?

The error messages are telling you that the XML is not valid according to the schema it's expecting:

  1. Where you have <filter-name> it's expecting one of <description>, <display-name>, <icon> or <servlet-name>.
  2. Your </servlet> tag (or possibly the opening <servlet>) appears to be in the wrong place

EDIT: I loaded the XML in Oxygen and it looks like the problem with <servlet> is actually because the <filter> tag just after it is misplaced.

0
votes

Today I encountered the similar error. My code shows below:

<servlet>
    <init-param>
        <param-name>data1</param-name>
        <param-value>value1</param-value>
    </init-param>
    <init-param>
        <param-name>data2</param-name>
        <param-value>value2</param-value>
    </init-param>
    <servlet-name>ServletConfigServlet</servlet-name>
    <servlet-class>com.netease.server.example.web.controller.ServletConfigServlet</servlet-class>
</servlet>

The error warning:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. 
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":servlet-name}' is expected.

I have tried some solution. Finally, I fixed it with changed the order of <init-param> and <servlet-name>, <servlet-class>. It looks like:

<servlet>
    <servlet-name>ServletConfigServlet</servlet-name>
    <servlet-class>com.netease.server.example.web.controller.ServletConfigServlet</servlet-class>
    <init-param>
        <param-name>data1</param-name>
        <param-value>value1</param-value>
    </init-param>
    <init-param>
        <param-name>data2</param-name>
        <param-value>value2</param-value>
    </init-param>
</servlet>

Hope this could help somebody. :D