title: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource
body: <p>I'm using maven project with hibernate 4</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
      &lt;version&gt;4.1.9.Final&lt;/version&gt;
      &lt;!-- will come with Hibernate core--&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>and spring 3.2.0.RELEASE and jsf in run tomcat server i have this exception :</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [application-context.xml]: 
  Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
  </code></pre>
  
  <p>this is my application-context.xml :</p>
  
  <pre><code>&lt;bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"&gt;&lt;/property&gt;
          &lt;property name="url" value="jdbc:mysql://localhost/gestionnotes"&gt;&lt;/property&gt;
          &lt;property name="username" value="root"&gt;&lt;/property&gt;
          &lt;property name="password" value=""&gt;&lt;/property&gt;  
      &lt;/bean&gt;
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="packagesToScan" value="fr.ensa.agadir.model"&gt;&lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
           &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
      &lt;context:annotation-config/&gt;
      &lt;context:component-scan base-package="fr.ensa.agadir"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>this is my pom.xml :</p>
  
  <blockquote>
    <p>http://maven.apache.org/maven-v4_0_0.xsd"></p>
    
    <p>4.0.0  EnsaAgadir
      EnsaGestionNotes   war
      EnsaGestionNotes Maven Webapp
      1.0-SNAPSHOT
    4.0.0
          EnsaAgadir
          EnsaGestionNotes
          war
          EnsaGestionNotes Maven Webapp
          1.0-SNAPSHOT</p>
  
  <pre><code>  &lt;!-- les proprietés 3.1.4 --&gt;
    &lt;properties&gt;
        &lt;logback.version&gt;0.9.15&lt;/logback.version&gt;
        &lt;spring.version&gt;3.2.0.RELEASE&lt;/spring.version&gt;
        &lt;slf4j.version&gt;1.7.7&lt;/slf4j.version&gt;
        &lt;env&gt;LOCAL&lt;/env&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
  
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
            &lt;artifactId&gt;commons-digester3&lt;/artifactId&gt;
            &lt;version&gt;3.2&lt;/version&gt;
        &lt;/dependency&gt;
  
        &lt;dependency&gt;
            &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
            &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
            &lt;version&gt;1.1.2&lt;/version&gt;
        &lt;/dependency&gt;
  
        &lt;dependency&gt;
            &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
            &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
            &lt;version&gt;1.9.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
            &lt;artifactId&gt;commons-beanutils-bean-collections&lt;/artifactId&gt;
            &lt;version&gt;1.8.3&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
            &lt;artifactId&gt;commons-dbcp2&lt;/artifactId&gt;
            &lt;version&gt;2.0.1&lt;/version&gt;
        &lt;/dependency&gt;
  
  
        &lt;dependency&gt;
            &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
            &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
            &lt;version&gt;2.2.6&lt;/version&gt;
            &lt;scope&gt;runtime&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
            &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
            &lt;version&gt;2.2.6&lt;/version&gt;
            &lt;scope&gt;runtime&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;!-- primafaces --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
            &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
            &lt;version&gt;5.0&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.primefaces.themes&lt;/groupId&gt;
            &lt;artifactId&gt;all-themes&lt;/artifactId&gt;
            &lt;version&gt;1.0.9&lt;/version&gt;
        &lt;/dependency&gt;
  
        &lt;!-- Junit 4 --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;junit&lt;/groupId&gt;
            &lt;artifactId&gt;junit&lt;/artifactId&gt;
            &lt;version&gt;4.0&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.1.9.Final&lt;/version&gt;
             &lt;!-- will come with Hibernate core--&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
            &lt;version&gt;4.3.5.Final&lt;/version&gt;
            &lt;type&gt;jar&lt;/type&gt;
            &lt;scope&gt;compile&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate.common&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-commons-annotations&lt;/artifactId&gt;
            &lt;version&gt;4.0.5.Final&lt;/version&gt;
            &lt;type&gt;jar&lt;/type&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.validation&lt;/groupId&gt;
            &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
            &lt;version&gt;1.0.0.GA&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
            &lt;version&gt;5.1.1.Final&lt;/version&gt;
        &lt;/dependency&gt;
  
        &lt;!-- Hibernate uses slf4j for logging, for our purposes here use the simple 
            backend --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
            &lt;artifactId&gt;slf4j-jdk14&lt;/artifactId&gt;
            &lt;version&gt;${slf4j.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
            &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
            &lt;version&gt;${slf4j.version}&lt;/version&gt;
        &lt;/dependency&gt;
  
        &lt;!-- Hibernate gives you a choice of bytecode providers between cglib and 
            javassist --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.javassist&lt;/groupId&gt;
            &lt;artifactId&gt;javassist&lt;/artifactId&gt;
            &lt;version&gt;3.18.2-GA&lt;/version&gt;
        &lt;/dependency&gt;
  
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-c3p0&lt;/artifactId&gt;
            &lt;version&gt;4.3.5.Final&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;!-- c3p0 dependency --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;c3p0&lt;/groupId&gt;
            &lt;artifactId&gt;c3p0&lt;/artifactId&gt;
            &lt;version&gt;0.9.1.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;!-- spring --&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;scope&gt;compile&lt;/scope&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;scope&gt;compile&lt;/scope&gt;
        &lt;/dependency&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;scope&gt;compile&lt;/scope&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;scope&gt;compile&lt;/scope&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-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-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-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;!-- MySql jdbc --&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.9&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;!-- jstl --&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;/dependency&gt;
  
  
        &lt;!-- javax.servlet --&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;/dependency&gt;
  
        &lt;!-- javax.servlet --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
            &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
            &lt;version&gt;2.5&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
            &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
            &lt;version&gt;2.1&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
  
        &lt;!-- upload --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
            &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
            &lt;version&gt;1.3.1&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;!-- upload --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax&lt;/groupId&gt;
            &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
            &lt;version&gt;7.0&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;!-- Itext --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.lowagie&lt;/groupId&gt;
            &lt;artifactId&gt;itext&lt;/artifactId&gt;
            &lt;version&gt;2.1.7&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
            &lt;artifactId&gt;poi&lt;/artifactId&gt;
            &lt;version&gt;3.5-beta3&lt;/version&gt;
        &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
  
    &lt;build&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;1.7&lt;/source&gt;
                    &lt;target&gt;1.7&lt;/target&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
        &lt;resources&gt;
          &lt;resource&gt;
            &lt;directory&gt;src/main/resources&lt;/directory&gt;
            &lt;filtering&gt;true&lt;/filtering&gt;
          &lt;/resource&gt;
        &lt;/resources&gt;
    &lt;/build&gt;
    &lt;repositories&gt;
        &lt;repository&gt;
            &lt;id&gt;jboss-repository&lt;/id&gt;
            &lt;name&gt;JBoss Public Maven Repository&lt;/name&gt;
            &lt;url&gt;https://repository.jboss.org/nexus/&lt;/url&gt;
        &lt;/repository&gt;
        &lt;repository&gt;
            &lt;id&gt;prime-repo&lt;/id&gt;
            &lt;name&gt;PrimeFaces Maven Repository&lt;/name&gt;
            &lt;url&gt;http://repository.primefaces.org&lt;/url&gt;
            &lt;layout&gt;default&lt;/layout&gt;
        &lt;/repository&gt;
        &lt;repository&gt;
            &lt;id&gt;java.net2&lt;/id&gt;
            &lt;name&gt;Repository hosting the jee6 artifacts&lt;/name&gt;
            &lt;url&gt;http://download.java.net/maven/2&lt;/url&gt;
        &lt;/repository&gt;
    &lt;/repositories&gt;
  &lt;/project&gt;
  </code></pre>
  </blockquote>