Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referenced file contains errors (http://java.sun.com/xml/ns/javaee/web-app.xsd)

I faced this error in Eclipse:

Referenced file contains errors (http://java.sun.com/xml/ns/javaee/web-app.xsd). For more information, right click on the message in the Problems View and select "Show Details..."

Can anyone help me? What is problem? Thanks in advance. My code is:

<?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.xsd">

    <!-- The definition of the Root Spring Container shared by all Servlets             and Filters -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/root-context.xml</param-value>
    </context-param>

    <!-- Creates the Spring Container shared by all Servlets and Filters -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- Processes application requests -->
    <servlet>
        <servlet-name>dispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/spring/dispatcherServlet/servlet-context.xml
            </param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcherServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>
like image 396
Shraddha Male Avatar asked Oct 15 '25 21:10

Shraddha Male


2 Answers

Try using this URL for the schema definition:

http://oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_0.xsd

As mentioned above by @Renardo, the following URL...

http://java.sun.com/xml/ns/javaee;http://java.sun.com/xml/ns/javaee/web-app.xsd 

...redirects to an HTML page that causes an error within Eclipse.

like image 80
Rohit Avatar answered Oct 17 '25 10:10

Rohit


I had the same problem although my schemaLocation points to web-app_3_0.xml. With 2_4 the problem did not appear. Now I have found that, used as an http address,

java.sun.com/xml/ns/j2ee/web-app_2_4.xsd

is redirected to

www.oracle.com/webfolder/technetwork/jsc/xml/ns/j2ee/web-app_2_4.xsd

which is a valid XSD file. However, the same URL with "3_0" instead of "2_4" is redirected to …/technetwork/java/index.html, which is an HTML file and contains exactly the texts Eclipse complains of.

I am at a loss as to whether

  • Oracle should provide an XSD under that URL, or
  • Eclipse should try to get that XSD from elsewhere, or
  • I should change my namespace declaration.

My Eclipse errors went away when I changed the namespace from "…/xml/ns/j2ee" to "…/xml/ns/javaee" and used a URL from Oracle's website that points to a correct XSD. Sorry I cannot post the URL, my low reputation does not allow it.

like image 36
Renardo Avatar answered Oct 17 '25 12:10

Renardo