title: Connection cannot be null when 'hibernate.dialect' not set hibernate4 tomcat7
body: <p>I've followed some tutorial in order to set up a web application using spring, hibernate to run on tomcat.</p>
  
  <p>When trying to run my application I get the error "Connection cannot be null when 'hibernate.dialect' not set"</p>
  
  <p>My hibernate.cfg.xml is</p>
  
  <pre><code>    &lt;?xml version='1.0' encoding='utf-8'?&gt;
     &lt;!DOCTYPE hibernate-configuration PUBLIC"-//Hibernate/Hibernate ConfigurationDTD//EN"
     "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
    &lt;hibernate-configuration&gt;
        &lt;session-factory&gt;
        &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
        &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/myproject&lt;/property&gt;
        &lt;property name="connection.username"&gt;root&lt;/property&gt;
    &lt;property name="connection.password"&gt;root&lt;/property&gt;
        &lt;mapping class="com.myproject.entity.user.UserEntity"&gt;&lt;/mapping&gt;
        &lt;mapping class="com.myproject.entity.user.UserAboutEntity"&gt;&lt;/mapping&gt;
        &lt;mapping class="com.myproject.entity.user.UserBasicInfoEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.UserDescriptionEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.UserInterestsEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.UserEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.UserPersonalViewsEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.UserPetsEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.UserSportsEntity"&gt;&lt;/mapping&gt;
  
      &lt;mapping class="com.myproject.entity.user.PartnerAboutEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.PartnerBasicInfoEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.PartnerDescriptionEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.PartnerInterestsEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.PartnerPersonalViewsEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.PartnerPetsEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.PartnerSportsEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.PartnerStyleEntity"&gt;&lt;/mapping&gt;
  
  
      &lt;mapping class="com.myproject.entity.user.MessagePageEntity"&gt;&lt;/mapping&gt;
      &lt;mapping class="com.myproject.entity.user.MessageEntity"&gt;&lt;/mapping&gt;
  
      &lt;mapping class="com.myproject.entity.user.MatchListEntity"&gt;&lt;/mapping&gt;
      &lt;/session-factory&gt;
      &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>My pom.xml</p>
  
  <pre><code>    &lt;project xmlns="http://maven.apache.org/POM/4.0.0"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
     &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
     &lt;groupId&gt;com.myproject.controller&lt;/groupId&gt;
     &lt;artifactId&gt;myproject&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
     &lt;packaging&gt;war&lt;/packaging&gt;
     &lt;name&gt;myproject Webapp&lt;/name&gt;
     &lt;url&gt;http://maven.apache.org&lt;/url&gt;
     &lt;properties&gt;  
     &lt;spring.version&gt;3.1.1.RELEASE&lt;/spring.version&gt;  
     &lt;/properties&gt; 
      &lt;build&gt;
            &lt;finalName&gt;myproject-webapp&lt;/finalName&gt;
             &lt;plugins&gt;
                &lt;plugin&gt;
                 &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; 
                 &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                 &lt;version&gt;3.1&lt;/version&gt;
                 &lt;configuration&gt;
                      &lt;source&gt;${jdk.version}&lt;/source&gt;  
                      &lt;target&gt;${jdk.version}&lt;/target&gt; 
                  &lt;/configuration&gt;
                &lt;/plugin&gt;
        &lt;plugin&gt;
                 &lt;groupId&gt;net.leadware&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate4-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;1.0.1&lt;/version&gt;
         &lt;/plugin&gt; 
             &lt;/plugins&gt;
           &lt;/build&gt;
           &lt;repositories&gt;
                &lt;repository&gt;
                     &lt;id&gt;repository.jboss.org-public&lt;/id&gt;
                     &lt;name&gt;JBoss repository&lt;/name&gt;
                     &lt;url&gt;https://repository.jboss.org/nexus/content/groups/public&lt;/url&gt;
                 &lt;/repository&gt;
              &lt;/repositories&gt;
              &lt;dependencies&gt;
              &lt;!-- Spring dependencies --&gt;
                  &lt;dependency&gt;
                     &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                      &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
                       &lt;version&gt;${spring.version}&lt;/version&gt;
                  &lt;/dependency&gt;
                   &lt;dependency&gt;
                        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
                        &lt;version&gt;${spring.version}&lt;/version&gt;
                   &lt;/dependency&gt;
                  &lt;dependency&gt;
                        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                        &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
                        &lt;version&gt;${spring.version}&lt;/version&gt;
                   &lt;/dependency&gt;
                   &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc-portlet&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
           &lt;/dependency&gt;
                   &lt;dependency&gt;
               &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
                 &lt;version&gt;${spring.version}&lt;/version&gt;
           &lt;/dependency&gt;
           &lt;dependency&gt;
             &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
             &lt;version&gt;${spring.version}&lt;/version&gt;
           &lt;/dependency&gt;
           &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
           &lt;/dependency&gt;
           &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
           &lt;/dependency&gt;
           &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-oxm&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- MySQL database driver --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;5.1.30&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Hibernate framework --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;4.2.7.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
          &lt;version&gt;4.2.7.Final&lt;/version&gt;
      &lt;/dependency&gt;        
  
      &lt;!-- Hibernate library dependecy start --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;dom4j&lt;/groupId&gt;
          &lt;artifactId&gt;dom4j&lt;/artifactId&gt;
          &lt;version&gt;1.6.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;commons-logging&lt;/groupId&gt;
          &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
          &lt;version&gt;1.1.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;commons-collections&lt;/groupId&gt;
          &lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
          &lt;version&gt;3.2.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;antlr&lt;/groupId&gt;
          &lt;artifactId&gt;antlr&lt;/artifactId&gt;
          &lt;version&gt;2.7.7&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- Hibernate library dependecy end --&gt;
  
      &lt;!-- Tomcat --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-dbcp&lt;/artifactId&gt;
          &lt;version&gt;7.0.52&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Log4J --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j&lt;/artifactId&gt;
          &lt;version&gt;1.2.15&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;javax.mail&lt;/groupId&gt;
                  &lt;artifactId&gt;mail&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;javax.jms&lt;/groupId&gt;
                  &lt;artifactId&gt;jms&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;com.sun.jdmk&lt;/groupId&gt;
                  &lt;artifactId&gt;jmxtools&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;com.sun.jmx&lt;/groupId&gt;
                  &lt;artifactId&gt;jmxri&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javassist&lt;/groupId&gt;
          &lt;artifactId&gt;javassist&lt;/artifactId&gt;
          &lt;version&gt;3.12.1.GA&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;taglibs&lt;/groupId&gt;
          &lt;artifactId&gt;standard&lt;/artifactId&gt;
          &lt;version&gt;1.1.2&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
          &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
          &lt;version&gt;1.4&lt;/version&gt;
      &lt;/dependency&gt;
          &lt;/dependencies&gt; 
      &lt;/project&gt;
  </code></pre>
  
  <p>user-servlet.xml</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:aop="http://www.springframework.org/schema/aop"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:jee="http://www.springframework.org/schema/jee"
  xmlns:lang="http://www.springframework.org/schema/lang"
  xmlns:p="http://www.springframework.org/schema/p"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:util="http://www.springframework.org/schema/util"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
      http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt;
  
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.findlove.controller" /&gt;
  
  &lt;bean id="jspViewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="viewClass"
          value="org.springframework.web.servlet.view.JstlView"&gt;&lt;/property&gt;
      &lt;property name="prefix" value="/WEB-INF/view/"&gt;&lt;/property&gt;
      &lt;property name="suffix" value=".jsp"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="messageSource"
      class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
      &lt;property name="basename" value="classpath:messages"&gt;&lt;/property&gt;
      &lt;property name="defaultEncoding" value="UTF-8"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="propertyConfigurer"
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
      p:location="/WEB-INF/jdbc.properties"&gt;&lt;/bean&gt;
  
  &lt;bean id="dataSource"
      class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
      p:driverClassName="${jdbc.driverClassName}"
      p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
      p:password="${jdbc.password}"&gt;&lt;/bean&gt;
  
  &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="packagesToScan" value="com.findlove.entity" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="userDAO" class="com.findlove.dao.user.UserDAOImpl"&gt;&lt;/bean&gt;
  &lt;bean id="userManager" class="com.findlove.service.user.UserManagerImpl"&gt;&lt;/bean&gt;
  
  &lt;tx:annotation-driven /&gt;
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>
  Any advice as to why I'm getting this error would be greatly appreciated.</p>
  
  <p>Lisa</p>