Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 无法读取架构文档';http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd_Hibernate_Jpa - Fatal编程技术网

Hibernate 无法读取架构文档';http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd

Hibernate 无法读取架构文档';http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd,hibernate,jpa,Hibernate,Jpa,我正在使用Hibernate和OracleXE为大学编写一个简单的Swing应用程序 我被那个错误缠住了: 29.06.2011 14:54:10 org.hibernate.cfg.annotations.Version <clinit> INFO: Hibernate Annotations 3.3.1.GA 29.06.2011 14:54:10 org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3

我正在使用Hibernate和OracleXE为大学编写一个简单的Swing应用程序

我被那个错误缠住了:

 29.06.2011 14:54:10 org.hibernate.cfg.annotations.Version <clinit>
 INFO: Hibernate Annotations 3.3.1.GA
 29.06.2011 14:54:10 org.hibernate.cfg.Environment <clinit>
 INFO: Hibernate 3.2.5
 29.06.2011 14:54:10 org.hibernate.cfg.Environment <clinit>
 INFO: hibernate.properties not found
 29.06.2011 14:54:10 org.hibernate.cfg.Environment buildBytecodeProvider
 INFO: Bytecode provider name : cglib
 29.06.2011 14:54:10 org.hibernate.cfg.Environment <clinit>
 INFO: using JDK 1.4 java.sql.Timestamp handling
 29.06.2011 14:54:10 org.hibernate.ejb.Version <clinit>
 INFO: Hibernate EntityManager 3.3.2.GA
 29.06.2011 14:54:31 org.hibernate.ejb.packaging.PersistenceXmlLoader$ErrorLogger warning
 WARNING: Warning parsing XML: XML InputStream(2) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.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>.
 29.06.2011 14:54:52 org.hibernate.ejb.packaging.PersistenceXmlLoader$ErrorLogger warning

链接断开了,你从哪里得到了它的参考资料,仔细检查一下。。。http ref应该可以工作,但显然不行,因为它不存在


快速的谷歌搜索表明有一个底线:将这一行添加到/etc/hosts文件可以解决这个问题:

127.0.0.1 java.sun.com
Hibernate似乎认识到这个和其他“标准”XSD-s是它所拥有的东西,并且在不访问Internet的情况下使用其内部副本没有问题

当XSD的HTTP GET未成功,但也未失败时,会出现问题: 返回其他内容或需要很长时间才能响应。 Hibernate没有为这些情况做好准备。 现在,URL需要很长时间才能响应,而Hibernate并没有像今天这样使用快速超时

没有互联网接入的系统不受影响


因此,作为一种解决方案,我通过将java.sun.com主机名解析为环回接口IP地址来模拟缺少Internet访问,从而保证快速故障。

在@Szocske的回答中,Hibernate似乎希望在不识别JPA 2.0 xsd版本的情况下从Internet检索该版本


我以前的Hibernate 3.2 JAR在尝试连接到Internet时,无意中使用了persistence.xml,它指定了版本2.0 xsd。因此,如果Hibernate正以这种方式运行,则可能表明XML和Hibernate JAR之间的版本不匹配。

如果您不想弄乱主机文件,您可以将schemaLocation更改为类路径资源

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee classpath:/com/sun/faces/web-facesconfig_2_0.xsd"
甚至是像这样的随机事件

xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com.file.was.not.there.so.changed.so.hibernate.takes.its.own.xsd.from.classpath.or.ignores.the.validation/xml/ns/persistence/orm_2_0.xsd"

所以这不是我的错,它可能会在一段时间内修复?要么是这样,要么是oracle永久性地更改/删除了模式定义。他们可能已经移动了它,但我怀疑他们是否会删除它。与此同时,无限连接挂起变成了对错误页面的重定向。我也面临着同样的问题,在添加127.0.0.1 java.sun.com之后,它也不起作用。它仍然显示未能读取架构文档“”作为警告
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee classpath:/com/sun/faces/web-facesconfig_2_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com.file.was.not.there.so.changed.so.hibernate.takes.its.own.xsd.from.classpath.or.ignores.the.validation/xml/ns/persistence/orm_2_0.xsd"