title: Hibernate not creating tables with Maven and Spring-mvc
body: <p>I have a simple project build with <code>maven2</code> and <code>Spring3MVC</code> running on TomCat 6. I want to have hibernate to create tables on runtime if they don't exist. However I had no success in it. Here are my files:</p>
  
  <p><code>hibernate.cfg.xml:</code></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 name="DKB"&gt;
      &lt;property name="hibernate.connection.driver_class"&gt;org.postgresql.Driver&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;dbk&lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:postgresql:dbk&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;dbk&lt;/property&gt;
      &lt;property name="hibernate.default_catalog"&gt;dbk&lt;/property&gt;
      &lt;property name="hibernate.default_schema"&gt;dbk&lt;/property&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/property&gt;
      &lt;property name="hibernate.hbm2ddl.auto"&gt;validate&lt;/property&gt;
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p><code>servlet-context.xml:</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:beans="http://www.springframework.org/schema/beans"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:mvc="http://www.springframework.org/schema/mvc"
  xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  &lt;mvc:annotation-driven /&gt;
  &lt;mvc:resources
  mapping="/resources/**"
  location="/resources/" /&gt;
  
  
  &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property
      name="prefix"
      value="/WEB-INF/views/" /&gt;
      &lt;property
      name="suffix"
      value=".jsp" /&gt;
  &lt;/bean&gt;
  &lt;bean
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      id="entityManagerFactory"&gt;
      &lt;property
      name="persistenceUnitName"
      value="jtdb" /&gt;
      &lt;property
      name="dataSource"
      ref="dataSource" /&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property
              name="showSql"
              value="true" /&gt;
              &lt;property
              name="generateDdl"
              value="true" /&gt;
              &lt;property
              name="databasePlatform"
              value="org.hibernate.dialect.PostgreSQLDialect" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
      &lt;property name="jpaProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
      &lt;context:component-scan base-package="pl.spot.dkb" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>and an example Entity Class:</p>
  
  <pre><code>import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "Roles")
  public class Role {
      @Id
      @GeneratedValue
      @Column(name = "id_r")
      int    id_r;
      @Column(name = "name")
      String name;
  
      public int getId_r() {
          return id_r;
      }
  
      public void setId_r(int id_r) {
          this.id_r = id_r;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>And part of <code>persistence.xml</code> with this class:</p>
  
  <pre><code>&lt;persistence-unit name="Role"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;class&gt;foo.bar.Role&lt;/class&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p>Is there something I'm missing out?</p>
  
  <p><strong>EDIT:</strong>
  Here's the TomCat log:</p>
  
  <pre><code>Using CATALINA_BASE:   "C:\Projekty\SpringMVC\Tomcat6"
  Using CATALINA_HOME:   "C:\Projekty\SpringMVC\Tomcat6"
  Using CATALINA_TMPDIR: "C:\Projekty\SpringMVC\Tomcat6\temp"
  Using JRE_HOME:        "C:\Program Files\Java\jdk1.6.0_26\jre\"
  Using CLASSPATH:       "C:\Projekty\SpringMVC\Tomcat6\bin\bootstrap.jar"
  2013-03-05 11:19:23 org.apache.catalina.core.AprLifecycleListener init
  INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C
  :\Program Files\Java\jdk1.6.0_26\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\app\K.Olejniczak\product\11.2.0\dbhome_1\bin;D:\app
  \K.Olejniczak\product\11.2.0\dbhome_2\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Progr
  am Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DT
  S\Binn\;"C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\";"C:\Program Files (x86)\GtkSharp\2.12\bin";"C:\Program Files (x86)\Java\jdk
  1.6.0_38\bin";C:\Program Files\TortoiseSVN\bin;D:\app\K.Olejniczak\product\11.2.0\dbhome_1\BIN;C:\Program Files (x86)\msls;C:\Program Files (x86)\Subv
  ersion\bin;C:\Program Files (x86)\gource;C:\Program Files\apache-ant-1.8.4\bin;D:\Research\PhoneGap\DevEnv\adt-bundle-windows-x86\sdk\tools;C:\Program
   Files (x86)\ant\bin;D:\Research\PhoneGap\DevEnv\Cordova\android\bin;"C:\Program Files (x86)\Tail for Win32";"C:\Program Files (x86)\apache-maven-3.0.
  4\bin";.
  2013-03-05 11:19:23 org.apache.coyote.http11.Http11Protocol init
  INFO: Initializing Coyote HTTP/1.1 on http-8080
  2013-03-05 11:19:23 org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 759 ms
  2013-03-05 11:19:23 org.apache.catalina.core.StandardService start
  INFO: Starting service Catalina
  2013-03-05 11:19:23 org.apache.catalina.core.StandardEngine start
  INFO: Starting Servlet Engine: Apache Tomcat/6.0.36
  2013-03-05 11:19:23 org.apache.catalina.startup.HostConfig deployDescriptor
  INFO: Deploying configuration descriptor host-manager.xml
  2013-03-05 11:19:23 org.apache.catalina.startup.HostConfig deployDescriptor
  INFO: Deploying configuration descriptor manager.xml
  2013-03-05 11:19:24 org.apache.catalina.startup.HostConfig deployWAR
  INFO: Deploying web application archive dbk.war
  INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
  INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Mar 05 11:19:25 CET
   2013]; root of context hierarchy
  INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root
  -context.xml]
  INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.suppor
  t.DefaultListableBeanFactory@41759d12: defining beans []; root of factory hierarchy
  INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 324 ms
  INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'springServlet': initialization started
  INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'springServlet-servlet': star
  tup date [Tue Mar 05 11:19:25 CET 2013]; parent: Root WebApplicationContext
  INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/spri
  ngServlet/servlet-context.xml]
  INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for compone
  nt scanning
  INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supporte
  d for autowiring
  INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.suppor
  t.DefaultListableBeanFactory@3d5b89c: defining beans [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springf
  ramework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,
  org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,
  org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionRe
  solver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springfra
  mework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.se
  rvlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,adminController,homeController,org.springf
  ramework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.s
  pringframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.spr
  ingframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.Def
  aultListableBeanFactory@41759d12
  INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/admin],methods=[GET],params=[],headers=[],consu
  mes=[],produces=[],custom=[]}" onto public java.lang.String foo.bar.admin.AdminController.adminHome(java.util.Locale,org.springframework.ui.Model)
  
  INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[
  ],produces=[],custom=[]}" onto public java.lang.String foo.bar.HomeController.home(java.util.Locale,org.springframework.ui.Model)
  INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet
  .resource.ResourceHttpRequestHandler#0'
  INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'springServlet': initialization completed in 8123 ms
  INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'adminServlet': initialization started
  INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'adminServlet-servlet': start
  up date [Tue Mar 05 11:19:33 CET 2013]; parent: Root WebApplicationContext
  INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/spri
  ngServlet/adminServlet-context.xml]
  INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for compone
  nt scanning
  INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supporte
  d for autowiring
  INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.suppor
  t.DefaultListableBeanFactory@1b609c13: defining beans [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.spring
  framework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0
  ,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0
  ,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionR
  esolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springfr
  amework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.s
  ervlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,adminController,org.springframework.conte
  xt.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework
  .context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.c
  ontext.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBe
  anFactory@41759d12
  INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/admin],methods=[GET],params=[],headers=[],consu
  mes=[],produces=[],custom=[]}" onto public java.lang.String foo.bar.admin.AdminController.adminHome(java.util.Locale,org.springframework.ui.Model)
  
  INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet
  .resource.ResourceHttpRequestHandler#0'
  INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'adminServlet': initialization completed in 190 ms
  2013-03-05 11:19:33 org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory docs
  2013-03-05 11:19:33 org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory examples
  2013-03-05 11:19:33 org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory ROOT
  2013-03-05 11:19:33 org.apache.coyote.http11.Http11Protocol start
  INFO: Starting Coyote HTTP/1.1 on http-8080
  2013-03-05 11:19:33 org.apache.jk.common.ChannelSocket init
  INFO: JK: ajp13 listening on /0.0.0.0:8009
  2013-03-05 11:19:33 org.apache.jk.server.JkMain start
  INFO: Jk running ID=0 time=0/24  config=null
  2013-03-05 11:19:34 org.apache.catalina.startup.Catalina start
  INFO: Server startup in 10451 ms
  </code></pre>