title: Am I configuring Hibernate hibernate.cfg.xml file correctly?
body: <p>I am using Hibernate (4.2.3) in a project for the first time. I am trying to get it to connect to an H2 embedded (local) DB and have the <code>h2-1.3.173.jar</code> on the classpath as well as all the Hibernate JARs. I'm getting some disturbing error messages from Hibernate in my log output that make me wonder if I am not configuring Hibernate correctly. Here is the output I'm seeing in the logs:</p>
  
  <pre><code>604 [main] INFO org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
  707 [main] INFO org.hibernate.Version - HHH000412: Hibernate Core {4.2.3.Final}
  769 [main] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found
  771 [main] INFO org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist
  2192 [main] INFO org.hibernate.cfg.Configuration - HHH000043: Configuring from resource: hibernate.cfg.xml
  2192 [main] INFO org.hibernate.cfg.Configuration - HHH000040: Configuration resource: hibernate.cfg.xml
  2835 [main] INFO org.hibernate.cfg.Configuration - HHH000041: Configured SessionFactory: null
  3313 [main] INFO org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl - HHH000402: Using Hibernate built-in connection pool (not for production use!)
  3313 [main] WARN org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl - HHH000148: No JDBC Driver class was specified by property hibernate.connection.driver_class
  3313 [main] INFO org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl - HHH000115: Hibernate connection pool size: 1
  3313 [main] INFO org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl - HHH000006: Autocommit mode: false
  </code></pre>
  
  <p>And here is my <code>hibernate.cfg.xml</code> file:</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://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;!-- DataSource &amp; Connection info. --&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.H2Dialect&lt;/property&gt;
          &lt;property name="hibernate.connection.driver.class"&gt;org.h2.Driver&lt;/property&gt;
          &lt;property name="hibernate.connection.url"&gt;jdbc:h2:file:/${MYAPP_HOME}/data/myapp_db&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;myapp&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;12345&lt;/property&gt;
          &lt;property name="hibernate.connection.pool_size"&gt;1&lt;/property&gt;
  
          &lt;!-- General Hibernate settings. --&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;property name="format_sql"&gt;true&lt;/property&gt;
          &lt;property name="use_sql_comments"&gt;true&lt;/property&gt;
  
          &lt;!-- DDL Mode. --&gt;
          &lt;property name="hbm2ddl.auto"&gt;validate&lt;/property&gt;
  
          &lt;!-- 2nd Level Cache. --&gt;
          &lt;property name="hibernate.cache.region.factory_class"&gt;net.sf.ehcache.hibernate.EhCacheRegionFactory&lt;/property&gt;
  
          &lt;!-- All our Hibernate mapping XML files. --&gt;
          &lt;mapping class="net.myapp.common.dto.WordDTO" /&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>From the log output, I am concerned about several things:</p>
  
  <ol>
  <li>Configured SessionFactory: null</li>
  <li>Using Hibernate built-in connection pool (not for production use!)</li>
  <li>No JDBC Driver class was specified by property hibernate.connection.driver_class</li>
  <li>Autocommit mode: false</li>
  </ol>
  
  <p>It <em>does</em> see that my connection pool size is 1, but I'm worried that this is a default value that Hibernate resorts to when it can't find/parse a <code>hibernate.cfg.xml</code> file. Why is my SessionFactory null? Why is Hibernate using it's own built-in connection pool? Why can't it find my JDBC Driver class when <code>h2-1.3.173.jar</code> is on the class path? What is "Autocommit mode" and why is it false?</p>
  
  <p>Thanks in advance!</p>