在Configuration.buildSessionFactory中,parse xxx.hbm.xml的时候,经常抛出UnknowHostException:hibernate.sourceforge.net,而我将DTD换成我本地的地址就可以了,难道一定要写上DTD引用的吗?如果我的server没连在internet上面,要把DTD放在本地,但我如果换了路径,那岂不是要将所有的XML都修改?
异常如下:
org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
at org.dom4j.io.SAXReader.read(SAXReader.java:358)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:286)
at dbdemo.HibernateDemo.run(HibernateDemo.java:53)
at dbdemo.HibernateDemo.main(HibernateDemo.java:31)
Nested exception:
java.net.UnknownHostException: hibernate.sourceforge.net
at java.net.InetAddress.getAllByName0(InetAddress.java:591)
at java.net.InetAddress.getAllByName0(InetAddress.java:560)
at java.net.InetAddress.getByName(InetAddress.java:469)
at java.net.Socket.<init>(Socket.java:121)
at sun.net.NetworkClient.doConnect(NetworkClient.java:65)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:361)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:548)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:296)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:318)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:466)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:562)
at java.net.URL.openStream(URL.java:826)
at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:748)
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:708)
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:258)
at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:833)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:525)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:581)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1158)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:286)
at dbdemo.HibernateDemo.run(HibernateDemo.java:53)
at dbdemo.HibernateDemo.main(HibernateDemo.java:31)
MappingException hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
java.lang.NullPointerException
at dbdemo.HibernateDemo.run(HibernateDemo.java:172)
at dbdemo.HibernateDemo.main(HibernateDemo.java:31)
Exception in thread "main"
Users.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="dbdemo.Users"
table="Users"
dynamic-update="false"
>
<id
name="userID"
column="LogonID"
type="string"
unsaved-value="any"
>
<generator class="assigned">
</generator>
</id>
<property
name="emailAddress"
type="string"
update="true"
insert="true"
column="EmailAddress"
/>
<property
name="lastLogon"
type="date"
update="true"
insert="true"
column="LastLogon"
/>
<property
name="password"
type="string"
update="true"
insert="true"
column="Password"
/>
<property
name="userName"
type="string"
update="true"
insert="true"
column="Name"
/>
<set
name="contacts"
table="Contacts"
lazy="false"
inverse="false"
cascade="all"
sort="unsorted"
>
<key
column="User_ID"
/>
<one-to-many
class="dbdemo.Contact"
/>
</set>
<set
name="books"
table="Book_User_Link"
lazy="false"
inverse="false"
cascade="all"
sort="unsorted"
>
<key
column="UserID"
/>
<many-to-many
class="dbdemo.Book"
column="BookID"
outer-join="auto"
/>
</set>
<one-to-one
name="address"
class="dbdemo.Address"
cascade="none"
outer-join="auto"
constrained="false"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-User.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
如果将文件头换成
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"file:///F:/hibernate-test/classes/hibernate-mapping-2.0.dtd">
就可以了。
----------------------------------------------------------------------
org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
at org.dom4j.io.SAXReader.read(SAXReader.java(Compiled Code))
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java(Compiled Code))
at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:383)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:990)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:275)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:193)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java(Compiled Code))
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java(Compiled Code))
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:230)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:304)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java(Compiled Code))
at java.lang.reflect.Constructor.newInstance(Constructor.java(Compiled Code))
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:73)
-----------------------------------------------------------------------本机调试时出现的情况:
由于我使用的Hibernate3.0 而 项目中使用的是Hibernate2.0 的所以出现上述错误,映射表要和2.0的一样,特别是DTD表头,望吸取教训,
分享到:
相关推荐
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar com.springsource.org.aopalliance-1.0.0.jar com.springsource.net.sf.cglib-2.2.0.jar
DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN"> -<hibernate-...
因为Hibernate在读出hbm.xml文件时需要通过网络读取到hibernate-mapping-3.0.dtd 文件。 如果没有网络不能正常工作。 所以提供上述文件。 以及hibernate-mapping-3.0.dtd,hibernate-configuration-3.0.dtd提供下载...
它是sourceforge.net上的一个开源项目,功能非常强大: + 支持同一汉字有多个发音 + 还支持拼音的格式化输出,比如第几声之类的, + 同时支持简体中文、繁体中文转换为拼音…使用起来也非常简单。下面是其官方...
#hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver #hibernate.connection.url jdbc:jtds:sqlserver://1E1/test ## Interbase #hibernate.dialect org.hibernate.dialect.InterbaseDialect #...
SimulIDE_0.4.14-SR4_Win64.zip 实时电子电路模拟器, 包括PIC,AVR和Arduino仿真。 下载:https://www.simulide.com/p/downloads.html 网站:...GpSim提供的PIC仿真:http://gpsim.sourceforge.net/
jar包,官方版本,自测可用
使用JSON,在SERVLET或者STRUTS的ACTION中取得数据时,如果会...http://json-lib.sourceforge.net/ http://ezmorph.sourceforge.net/ http://morph.sourceforge.net/ 本资源里面已经包含这些jar包,及json相关的js文件
[Download](https://img.shields.io/sourceforge/dm/glew.svg)](https://sourceforge.net/projects/glew/files/latest/download) ## Downloads Current release is [2.1.0]...
《深入理解Hibernate配置与映射:hibernate-configuration-3.0.dtd与hibernate-mapping-3.0.dtd解析》 在Java世界里,Hibernate作为一款强大的对象关系映射(ORM)框架,极大地简化了数据库操作。而`hibernate-...
hibernate-mapping-3.0.dtd 最新从官网下载,无损无修改
- [http://propedit.sourceforge.jp/index_en.html](http://propedit.sourceforge.jp/index_en.html) 5. **ColorerTake**: - [http://colorer.sourceforge.net/](http://colorer.sourceforge.net/) 6. **...
1. SourceForge(http://www.sourceforge.net):世界上最大的 Open Source 项目在线网站,上面已经有.NET 的各种大型 Open Source 项目上千件,包括 SharpDevelop、NDoc、Mono 等都是在此站点发布最新源代码信息。...
本文为Source-Navigator的帮助文档。...文档地址: http://sourcenav.sourceforge.net/online-docs/index.html 下载地址: http://sourcenav.sourceforge.net/download.html 收录时间: 2009年03月19日
http://www.fourmilab.ch/ http://netpbm.sourceforge.net/ 详情: 光谱的色彩渲染, John Walker http://www.fourmilab.ch/documents/specrend/ --------------------------------------------------------- CIE ...
DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">` 定义了此XML文件遵循的DTD(Document Type ...
需要去sourceforge.net下载软件,使用电信,移动等的宽带又进不去的亲们,可以通过该软件下载。 本软件系自己使用方便开发,完全免费发布给大家使用,功能不受限制。本人使用移动3g,不能浏览sourceforge网站,所以...
Please refer to http://grub4dos.sourceforge.net/wiki/ for DOCs on GRUB4DOS. Main project page: https://gna.org/projects/grub4dos/ Download site: http://download.gna.org/grub4dos/ Download site: ...
安装jpcap报错:Exception in thread "main" java.lang.UnsatisfiedLinkError: C:/Windows/System32/Jpcap.dll: Can't find dependent libraries 解决办法。