eclipse 引用的文件包含错误 (http://java.sun.com/xml/ns/javaee/web-app.xsd)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33796485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Referenced file contains errors (http://java.sun.com/xml/ns/javaee/web-app.xsd)
提问by Shraddha Male
I faced this error in Eclipse:
我在 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..."
引用的文件包含错误 ( http://java.sun.com/xml/ns/javaee/web-app.xsd)。有关更多信息,请右键单击问题视图中的消息并选择“显示详细信息...”
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>
回答by Rohit
Try using this URL for the schema definition:
尝试将此 URL 用于架构定义:
http://oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_0.xsd
As mentioned above by @Renardo, the following URL...
正如@Renardo 上面提到的,以下 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.
...重定向到导致 Eclipse 错误的 HTML 页面。
回答by Renardo
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,
尽管我的 schemaLocation 指向 web-app_3_0.xml,但我遇到了同样的问题。使用 2_4 没有出现问题。现在我发现,用作http地址,
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.
这是一个有效的 XSD 文件。但是,带有“3_0”而不是“2_4”的相同 URL 被重定向到…/technetwork/java/index.html,这是一个 HTML 文件,包含 Eclipse 抱怨的文本。
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.
- Oracle 应在该 URL 下提供 XSD,或
- Eclipse 应该尝试从其他地方获取该 XSD,或者
- 我应该更改我的命名空间声明。
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.
当我将命名空间从“.../xml/ns/ j2ee”更改为“.../xml/ns/ javaee”并使用 Oracle 网站上指向正确 XSD 的 URL时,我的 Eclipse 错误消失了。对不起,我不能发布 URL,我的低声誉不允许它。
回答by Heena
<?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
看起来问题出在 MyEclipse 附带的 Java EE JAR 上……我永远不会鼓励您将插件从一个版本复制到另一个版本(仅供将来参考,这可能会导致奇怪的问题)。所以试试上面一个