title: Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Unable to read XML
body: <p>I am doing <a href="http://www.lulu.com/shop/arulkumaran-kumaraswamipillai-and-sivayini-arulkumaran/tutorial-java-maven-2-eclipse-jsf/ebook/product-1603040.html;jsessionid=0C532C55C373D3DDB01AC49ACE23A5E2" rel="nofollow">this tutorial</a></p>
  
  <p>I am getting this following error:</p>
  
  <blockquote>
    <p>Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Unable to read XML</p>
  </blockquote>
  
  <p>Here is full error message:</p>
  
  <pre><code>Nov 18, 2012 9:52:46 PM org.hibernate.internal.util.xml.ErrorLogger logErrors
  ERROR: HHH000196: Error parsing XML (2) : Element type "generate" must be declared.
  Nov 18, 2012 9:52:46 PM org.hibernate.internal.util.xml.ErrorLogger logErrors
  ERROR: HHH000196: Error parsing XML (2) : The content of element type "id" must match "(meta*,column*,type?,generator?)".
  Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Unable to read XML
  Exception in thread "main" java.lang.ExceptionInInitializerError
      at com.mytutorial.CourseDaoImpl.&lt;clinit&gt;(CourseDaoImpl.java:19)
      at com.mytutorial.CourseServiceImpl.processCourse(CourseServiceImpl.java:10)
      at com.mytutorial.App.main(App.java:21)
  Caused by: org.hibernate.InvalidMappingException: Unable to read XML
      at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:109)
      at org.hibernate.cfg.Configuration.add(Configuration.java:478)
      at org.hibernate.cfg.Configuration.add(Configuration.java:474)
      at org.hibernate.cfg.Configuration.add(Configuration.java:647)
      at org.hibernate.cfg.Configuration.addResource(Configuration.java:730)
      at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2115)
      at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2087)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2067)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2020)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1935)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1914)
      at com.mytutorial.CourseDaoImpl.&lt;clinit&gt;(CourseDaoImpl.java:15)
      ... 2 more
  Caused by: org.xml.sax.SAXParseException: Element type "generate" must be declared.
      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)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1929)
      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:785)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
      at org.dom4j.io.SAXReader.read(SAXReader.java:465)
      at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:78)
      ... 13 more
  </code></pre>
  
  <p><strong>hibernate.cfg.xml</strong> is the following:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt; 
  &lt;!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt; 
  
      &lt;session-factory&gt;
          &lt;!-- Database connection settings --&gt;
          &lt;property name="connection.driver_class"&gt;org.hsqldb.jdbcDriver&lt;/property&gt; 
          &lt;property name="connection.url"&gt;jdbc:hsqldb:hsql://localhost&lt;/property&gt; 
          &lt;property name="connection.username"&gt;sa&lt;/property&gt;
          &lt;property name="connection.password"&gt;&lt;/property&gt;
  
  
          &lt;!-- JDBC connection pool (use the built-in) --&gt; 
          &lt;property name="connection.pool_size"&gt;2&lt;/property&gt;
  
          &lt;!-- SQL dialect --&gt;
          &lt;property name="dialect"&gt;org.hibernate.dialect.HSQLDialect&lt;/property&gt;
  
          &lt;!-- Drop and re-create the database schema on start-up, also try with “update” to keep the previous values --&gt;
          &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt; 
  
  
          &lt;!-- Echo all executed SQL to stdout --&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;mapping resource="com/mytutorial/Course.hbm.xml"/&gt; 
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p><strong>Course.hbm.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  
  
  &lt;hibernate-mapping&gt;
  
      &lt;class name="com.mytutorial.Course" table="Course"&gt;
          &lt;id name="id" column="course_id"&gt;
              &lt;generate class="native"/&gt;
          &lt;/id&gt;
  
          &lt;property name="name" column="name"/&gt;
          &lt;property name="course" column="course"/&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>I would be really appreciated if someone can help me.</p>