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>

Advertisements

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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Blog Stats

  • 221,338 hits

%d bloggers like this: