26
Feb
11

Hibernate exceptions 0.01 Caused by: org.xml.sax.SAXParseException: The content of element type “session-factory” must match “(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)”.



I received this:


Caused by: org.xml.sax.SAXParseException: The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".

Seems to have been caused because I had this in my hibernate.cfg.xml:


<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost</property>
    <property name="hibernate.connection.username">sa</property>
    <mapping class="h1.User" file="" jar="" package="" resource="User.hbm.xml"/>
    <property name="hbm2ddl.auto">update</property>
  </session-factory>
</hibernate-configuration>

It got fixed after I put the properties sequentially, like this:


<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost</property>
    <property name="hibernate.connection.username">sa</property>
    <property name="hbm2ddl.auto">update</property>
    <mapping class="h1.User" file="" jar="" package="" resource="User.hbm.xml"/>
  </session-factory>
</hibernate-configuration>


2 Responses to “Hibernate exceptions 0.01 Caused by: org.xml.sax.SAXParseException: The content of element type “session-factory” must match “(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)”.”


  1. February 1, 2012 at 06:27

    So weird, yet true. Thanks for your post. It was helpful.

  2. 2 Sam Mohamed
    September 25, 2012 at 21:33

    Live saver post…….. thanks a billion.


Leave a comment


Blog Stats

  • 281,967 hits