首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > 高性能WEB开发 >

使用Hibernate操作,出现org.hibernate.InvalidMappingException: Unable to read XML,该怎么解决

2013-11-13 
使用Hibernate操作,出现org.hibernate.InvalidMappingException: Unable to read XMLhibernate.cfg.xml:?

使用Hibernate操作,出现org.hibernate.InvalidMappingException: Unable to read XML
hibernate.cfg.xml:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
          
<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
<property name="dialect">
org.hibernate.dialect.SQLServerDialect
</property>
<property name="connection.url">
jdbc:sqlserver://192.168.2.3:1433;databaseName=YXKQGIS
</property>
<property name="connection.username">et</property>
<property name="connection.password">et</property>
<property name="connection.driver_class">
com.microsoft.sqlserver.jdbc.SQLServerDriver
</property>
<property name="myeclipse.connection.profile">
Etrans_YXKQGIS
</property>
<mapping resource="et/pojo/CityComponent.hbm.xml" />
</session-factory>
</hibernate-configuration>


CityComponent.hbm.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd ">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="et.pojo.CityComponent" table="YXKQGIS_CityComponent" schema="dbo" catalog="YXKQGIS">
        <id name="id" type="string">
            <column name="ID" length="20" />
            <generator class="assigned"></generator>
        </id>
        <property name="nameplate" type="string">
            <column name="Nameplate" length="50" not-null="true" />
        </property>
        <property name="model" type="string">
            <column name="Model" length="20" not-null="true" />
        </property>
        <property name="buildTime" type="timestamp">
            <column name="BuildTime" length="23" />
        </property>
        <property name="manageUnitName" type="string">
            <column name="ManageUnitName" length="50" />
        </property>
        <property name="manageUnitAddress" type="string">
            <column name="ManageUnitAddress" length="800" />
        </property>
        <property name="manageUnitLinkman" type="string">
            <column name="ManageUnitLinkman" length="50" />
        </property>
        <property name="manageUnitContactNumber" type="string">
            <column name="ManageUnitContactNumber" length="50" />
        </property>
        <property name="manageUnitContactAddress" type="string">
            <column name="ManageUnitContactAddress" length="500" />
        </property>
        <property name="principal" type="string">
            <column name="Principal" length="50" />
        </property>
        <property name="principalContactNumber" type="string">
            <column name="PrincipalContactNumber" length="50" />
        </property>
        <property name="principalContactAddress" type="string">


            <column name="PrincipalContactAddress" length="500" />
        </property>
        <property name="picture" type="binary">
            <column name="Picture" />
        </property>
        
    </class>
</hibernate-mapping>


这些配置文件、POJO类等等都是MyEclipse 10.7自动生成的。


MyEclipse工具Console输出内容:
2013-8-5 14:26:34 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2013-8-5 14:26:35 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.4.Final}
2013-8-5 14:26:35 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
2013-8-5 14:26:35 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2013-8-5 14:26:35 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
2013-8-5 14:26:35 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
2013-8-5 14:26:35 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: et/pojo/CityComponent.hbm.xml
org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:109)
at org.hibernate.cfg.Configuration.add(Configuration.java:478)
at org.hibernate.cfg.Configuration.add(Configuration.java:474)
at org.hibernate.cfg.Configuration.add(Configuration.java:647)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:730)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2109)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2081)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2061)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2014)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1929)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1908)
at et.util.HibernateOpera.<init>(HibernateOpera.java:14)
at et.interf.Login.checkLogin(Login.java:31)
at org.apache.jsp.accept.LoginAcp_jsp._jspService(LoginAcp_jsp.java:74)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.dom4j.DocumentException: http://www.jboss.org/dtd/hibernate/hibernate-mapping-3.0.dtd%20 Nested exception: http://www.jboss.org/dtd/hibernate/hibernate-mapping-3.0.dtd%20
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:78)
... 31 more


求解,希望各位高手帮帮忙,在线等,谢谢! Hibernate?Operate
[解决办法]
http://bbs.csdn.net/topics/350110378
看来你没有好好找答案啊! 好像是Configuration! 试试嘛!希望对你有帮助!
[解决办法]


这个下面的异常 你一下发上来这么多看的人瞬间感觉兴趣就不高了……把主要报的异常发一下就可以了么……那些信息就别发了啊 
[解决办法]
DTD文件路径的问题,
http://blog.csdn.net/mydeman/article/details/6134820
大概这些都对你有帮助! 我还没遇到这种问题,所以就只能给你提供一下别人的解决了的例子!自己去看吧
[解决办法]
学习了,,抬头导入的dtd文件错误 真的是防不胜防。。

热点排行