4

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>
1
  • You should add the error messages to your question. Commented Nov 19, 2015 at 7:05

4 Answers 4

6

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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.

1 Comment

"my low reputation does not allow it." lol
1
<?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" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

It looks like the problem was with the Java EE JARs that ship with MyEclipse… i would never encourage you to copy around plugins from one release to another (just for future reference, it could lead to squirrely problems). so try above one

1 Comment

must add the version property
1

Every time that I get this error I do this

Project -> Properties -> Project Facets In the right panel looking for Dynamic Web Module and get this version.

For example in my project I'm using Dynamic Web Module 3.1

With this I need to use http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
    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_3_1.xsd">
</weblogic-web-app>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.