`
Eric.Yan
  • 浏览: 318407 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Failed to read schema document

    博客分类:
  • XML
阅读更多

问题描述:

web项目web.xml编译错误:

schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd', because 1)  could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

 

解决方案:

多方查找,终不得解决,最后,format了一下格式,问题得以解决。

compile error format:

<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">

 

no error format:

<web-app version="2.5" 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">

 

不禁要问,非常奇怪,居然还可以这样。

原理呢,代码是没有问题的,都是那么写的,至于编译错误嘛应该是和开发工具有关系,我用的是eclipse juno-r2(4.2)的,这个版本不好,经常出一些莫名奇妙的问题,有时候打断点没用,不能debug,

哎.....现在最新的version是4.3(kepler),但是呢又不支持websphere7.0的plugin,真是很麻烦,就先这样勉强用着吧。扯多了,关于这个问题,搜的一些资料,参考下:

 

写道

Failed to read schema document 'http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd', because 1)

你看一下这个文件存不存在
2011-05-13 10:05 推荐: 0 次
编译器报的错,不用理他,实际发布后是不需要的
2011-05-13 10:13 推荐: 0 次
如果是MyEclipse他会联网自动找的
2011-05-13 10:13 推荐: 0 次
你的web.xml配置是没有问题的。
可能是环境的问题。。。
2011-05-13 10:15 推荐: 0 次
引用 2 楼 xihuanni0509 的回复:
Failed to read schema document 'http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd', because 1)

你看一下这个文件存不存在


这个文件在什么位置啊?
2011-05-13 10:30 推荐: 0 次
引用 3 楼 x19881216 的回复:
编译器报的错,不用理他,实际发布后是不需要的


但是我tomcat启动,有提示找不到web.xml
Severity Description Resource In Folder Location Creation Time Id
2 cvc-elt.1: Cannot find the declaration of element 'web-app'. web.xml Test/WebContent/WEB-INF line 2 2011年5月12日 9:11:46 1
并且访问http://localhost:8080时出现404错误。

我用的是Eclipse3.1
2011-05-13 10:38 推荐: 0 次
tomcat根本就没有安装成功呀
2011-05-13 10:43 推荐: 0 次
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

红色部门去掉
2011-05-13 10:46 推荐: 0 次
引用 9 楼 lrbyantai 的回复:

<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun……

+1
2011-05-13 10:50 推荐: 0 次
引用 9 楼 lrbyantai 的回复:
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.……


去掉后,提示
Severity Description Resource In Folder Location Creation Time Id
2 cvc-elt.1: Cannot find the declaration of element 'web-app'. web.xml Test/WebContent/WEB-INF line 2 2011年5月12日 13:44:50 7
还是有问题,是不是web-app不识别了
2011-05-13 12:48 推荐: 0 次
引用 9 楼 lrbyantai 的回复:
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.……


正解,lz加油
2011-05-14 08:20 推荐: 0 次
楼主,你用的是tomcat吗?

修改server.xml中的xmlvalidation=false
2011-05-14 09:38 推荐: 0 次
引用 13 楼 lrbyantai 的回复:
楼主,你用的是tomcat吗?

修改server.xml中的xmlvalidation=false

是用的tomcat 多谢 我试试
2011-05-14 16:07 推荐: 0 次
换一个Schma试试:
<?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">
</web-app>

同时你注意web.xml的位置,需在WEB-INF下。

 

<!-- 
	xmlns 声明默认的命名空间
	xmlns:context 声明context命名空间
	xmlns:p 声明p命名空间,用于简化spring配置文件中属性声明的写法 
	xmlns:mvc 声明mvc命名空间
	xmlns:xsi 声明XML Schema实例名称空间,并将xsi前缀与该命名空间绑定
	xsi:schemaLocation 引入Schema模式文档,解析器使用文档对xml进行校验,它的值是成对出现的,
		第一个表示命名空间,第二个表示该命名空间模式文档位置,中间用空格隔开
	如果抛出Failed to read schema document异常,是因为无法访问网址
 -->

有问题大家交流,共同进步!

 

分享到:
评论

相关推荐

    dubbo.xsd文件分享

    dubbo.xsd 下载 添加 xsd 源码位置获得:dubbo-config\dubbo-config-spring\src\main\resources\META-INF\dubbo.xsd

    dubbo找不到dubbo.xsd报错

    - schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root ...

    解决dubbo找不到dubbo.xsd报错

    - schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root ...

    dubbo.xsd文件下载

    - schema_reference.4: Failed to read schema document 'http:// code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root ...

    dubbo.xsd文件资源

    - schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root ...

    解决:dubbo找不到dubbo.xsd报错

    - schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root ...

    dubbo.xsd 约束文件 解决标签识别报红

    - schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root ...

    dubbo.xsd 下载

    org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could ...

Global site tag (gtag.js) - Google Analytics