3

I have been struggling to fix this error from long time Kindly help me in this.

I am getting ERROR: HHH000196: Error parsing XML (2) : Element type "hibernate-mapping" must be declared.

Please help me to fix this:

My pom.xml looks like this:

<dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.2.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.2.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.3.1.Final</version>
        </dependency>

My cfg.xml header:

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

My 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-configuration-3.0.dtd">
<hibernate-mapping>
    <class name="com.kivar.lumina.server.segment.Segment" table="segments">
        <id column="ID" name="id" type="java.lang.Long">
        </id>
    </class>
</hibernate-mapping>

2 Answers 2

4

Location URL of DTD is wrong. In hbm.xml hibernate-mapping-3.0.dtd should be used instead of hibernate-configuration-3.0.dtd as in following:

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
Sign up to request clarification or add additional context in comments.

Comments

1

The solution in accepted answer is safe. Of course, there should be DTD for mapping rather than configuration, but the URL is

http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd

since Hibernate 3.6. See https://developer.jboss.org/wiki/HibernateCoreMigrationGuide36

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.