例外:元素类型“hibernate-mapping”的内容必须匹配“

时间:2011-12-01 20:54:35

标签: xml hibernate exception hibernate-mapping

我收到以下错误:

<my correct path>/applicationContext_AuthService.xml]: Invocation of init method failed;     nested exception is org.hibernate.InvalidMappingException: Unable to read XML

然后进一步向下揭示了原因:

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。在那里,我有以下映射:

    <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。这是该文件:

    <?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。

有人对我做错了什么有任何想法吗?

提前致谢,

安德鲁

1 个答案:

答案 0 :(得分:1)

你错过了最后一行,除非这是一个复制粘贴错误:

</hibernate-mapping>

你能确认这是这个档案吗?尝试将其评论出来,看看错误是否消失(或者给出了不同的错误)。