title: Error creating bean sessionFactory
body: <p>I am integrating Spring with Hibernate. However, when I run the application I get an error like:</p>
  
  <blockquote>
    <p>Error creating bean with name 'sessionFactory' defined in class path resource [resources/spring.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory</p>
  </blockquote>
  
  <p>My spring.xml looks like:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
  &lt;bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt;
      &lt;property name="driverClassName" value="org.postgresql.Driver" /&gt;
      &lt;property name="url" value="jdbc:postgresql://localhost:5432/3encult" /&gt;
      &lt;property name="password" value="3encult" /&gt;
      &lt;property name="username" value="3encult" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="myDataSource" /&gt;
      &lt;property name="mappingResources"&gt;
          &lt;list&gt;
              &lt;value&gt;
                  resources/User.hbm.xml
                  &lt;!-- Project.hbm.xml ProjCF.hbm.xml Task.hbm.xml TaskCF.hbm.xml Category.hbm.xml 
                      TaskEstimation.hbm.xml ProjectEstimation.hbm.xml Parameter.hbm.xml StatisticTool.hbm.xml 
                      Report.hbm.xml --&gt;
              &lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt;
              &lt;!-- Especificamos el valor minimo del pool de conexiones --&gt;
              &lt;prop key="hibernate.c3p0.minPoolSize"&gt;5&lt;/prop&gt;
              &lt;!-- Especificamos el valor maximo del pool de conexiones --&gt;
              &lt;prop key="hibernate.c3p0.maxPoolSize"&gt;20&lt;/prop&gt;
              &lt;!-- El tiempo de vida de cada conexion del pool. --&gt;
              &lt;prop key="hibernate.c3p0.timeout"&gt;600&lt;/prop&gt;
  
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="myUserDAO" class="main.java.com.gwt.app.server.User"&gt;
      &lt;property name="sesionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>And the injection in class User is:</p>
  
  <pre><code>ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"resources/spring.xml"});
  
  public void setSesionFactory(SessionFactory sesionFactory){
      this.sesionFactory = sesionFactory;
      this.sesion = this.sesionFactory.openSession();
  }
  </code></pre>
  
  <p>The stacktrace is:</p>
  
  <pre><code>Error creating bean with name 'sessionFactory' defined in class path resource [resources/spring.xml]: Invocation of init method failed; nested exception is    org.hibernate.HibernateException: Unable to get the default Bean Validation factory
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [resources/spring.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:900)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:455)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:93)
  at main.java.com.gwt.app.server.User.&lt;init&gt;(User.java:16)
  at main.java.com.gwt.app.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:20)
  at main.java.com.gwt.app.client.Main.main(Main.java:10)
   Caused by: org.hibernate.HibernateException: Unable to get the default Bean Validation factory
  at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:127)
  at org.hibernate.cfg.Configuration.applyBeanValidationConstraintsOnDDL(Configuration.java:1677)
  at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1627)
  at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1418)
  at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1348)
  at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
  at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
  ... 14 more
  Caused by: java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:118)
  ... 22 more
  Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory
  at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:383)
  at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:109)
  ... 27 more
  Caused by: javax.validation.ValidationException: Unable to find a default provider
  at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:264)
  at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
  at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:380)
  ... 28 more
  </code></pre>
  
  <p>Build path contains the following libraries:</p>
  
  <pre><code>hibernate3.jar
  org.springframework.aop-3.1.0.M1.jar
  org.springframework.asm-3.1.0.M1.jar
  org.springframework.aspects-3.1.0.M1.jar
  org.springframework.beans-3.1.0.M1.jar
  org.springframework.context-3.1.0.M1.jar
  org.springframework.context.support-3.1.0.M1.jar
  org.springframework.core-3.1.0.M1.jar
  org.springframework.expression-3.1.0.M1.jar
  org.springframework.instrument-3.1.0.M1.jar
  org.springframework.instrument.tomcat-3.1.0.M1.jar
  org.springframework.jdbc-3.1.0.M1.jar
  org.springframework.jms-3.1.0.M1.jar
  org.springframework.orm-3.1.0.M1.jar
  org.springframework.oxm-3.1.0.M1.jar
  org.springframework.transaction-3.1.0.M1.jar
  </code></pre>
  
  <p>I am not using validation. It is the reason of not include the validation jar.</p>
  
  <p>I do not know what happens, I would like someone could help me.</p>
  
  <p>Thanks!</p>