首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >异常:元素类型"hibernate-mapping“的内容必须匹配”

异常:元素类型"hibernate-mapping“的内容必须匹配”
EN

Stack Overflow用户
提问于 2011-12-02 04:54:35
回答 1查看 6.2K关注 0票数 0

我得到以下错误:

代码语言:javascript
复制
<my correct path>/applicationContext_AuthService.xml]: Invocation of init method failed;     nested exception is org.hibernate.InvalidMappingException: Unable to read XML

再往下看,原因就被揭示了:

代码语言:javascript
复制
Caused by: org.xml.sax.SAXParseException: The content of element type "hibernate-mapping" must match "(meta*,identifier-generator*,typedef*,filter-def*,import*,(class|subclass|joined-subclass|union-subclass)*,resultset*,(query|sql-query)*,filter-def*,fetch-profile*,database-object*)".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)

例外情况是引用文件applicationContext_AuthService.xml。在那里,我有以下映射:

代码语言:javascript
复制
    <bean id="UserAPPSessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref bean="UserAPP" />
    </property>
    <property name="mappingResources">
        <list>
            <!-- value>hib/userapp/ActionImpl.hbm.xml</value -->
            <value>hib/userapp/ActivityCode.hbm.xml</value>
            <value>hib/userapp/Authorization.hbm.xml</value>
            <value>hib/userapp/Contacts.hbm.xml</value>
            <value>hib/userapp/CorrectionRequests.hbm.xml</value>
            <!-- value>hib/userapp/CSRHistory.hbm.xml</value -->
            <value>hib/userapp/Csrusers.hbm.xml</value>
            <value>hib/userapp/Customer.hbm.xml</value>
            <value>hib/userapp/CustomerTypeImpl.hbm.xml</value>
            <value>hib/userapp/DocumentAssociationCrosswalk.hbm.xml</value>
            <value>hib/userapp/DocumentImpl.hbm.xml</value>
            <value>hib/userapp/KeyDB.hbm.xml</value>
            <value>hib/userapp/KeyDBFirst.hbm.xml</value>
            <value>hib/userapp/NotesImpl.hbm.xml</value>
            <value>hib/userapp/Product.hbm.xml</value>
            <value>hib/userapp/RatesImpl.hbm.xml</value>
            <value>hib/userapp/ReminderImpl.hbm.xml</value>
            <value>hib/userapp/YearImpl.hbm.xml</value>
        </list>
    </property>

第二个是hib/userapp/Authorization.hbm.xml。以下是该文件:

代码语言:javascript
复制
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Generated Aug 17, 2011 3:35:48 PM by Hibernate Tools 3.4.0.CR1 -->
    <hibernate-mapping>
        <class name="com.eagle.customer.impl.AuthorizationImpl" table="CustomerAuthorization"
    schema="dbo" catalog="UserAPP">
    <cache usage="read-write" />
    <id name="custId" type="string">
        <column name="CustID" length="10" />
        <generator class="assigned" />
    </id>
    <property name="password" type="string">
        <column name="Password" length="15" />
    </property>
    <property name="custType" type="string">
        <column name="CustType" length="10" />
    </property>
    <property name="authLevel" type="string">
        <column name="AuthLevel" length="2" />
    </property>
    <property name="custStatus" type="string">
        <column name="CustStatus" length="10" />
    </property>
    <property name="vincaptureHbm" type="string">
        <column name="VINCapture" length="1" />
    </property>
    <property name="mileageReportHbm" type="string">
        <column name="MileageReport" length="1" />
    </property>
</class>

这就是我认为它在抱怨的那个。根据XMLSpy,它是有效的xml。

有谁知道我哪里做错了吗?

提前谢谢你,

安德鲁

EN

回答 1

Stack Overflow用户

发布于 2011-12-06 01:17:15

您遗漏了最后一行,除非这是一个复制-粘贴错误:

代码语言:javascript
复制
</hibernate-mapping>

你能确认就是这个文件吗?尝试注释掉它,看看错误是否消失(或者给出一个不同的错误)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8348158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档