title: beans.factory.BeanCreationException: Error creating bean with name 'dao': Injection of persistence dependencies failed
body: <p>I am trying to run my project, but I get these following exceptions:</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dao': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: MY_P_U] Unable to build EntityManagerFactory
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:342)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
  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 test.Test.main(Test.java:9) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: MY_P_U] Unable to build EntityManagerFactory
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
  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:294)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:530)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:496)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:657)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:630)
  at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
  at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:339)
  ... 13 more Caused by: javax.persistence.PersistenceException: [PersistenceUnit: MY_P_U] Unable to build EntityManagerFactory
  at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:911)
  at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
  at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268)
  at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
  ... 26 more Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: org.gestion.infopanne.entities.simplemessage column: genre (should be mapped with insert="false" update="false")
  at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:675)
  at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:697)
  at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:719)
  at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:473)
  at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:65)
  at org.hibernate.cfg.Configuration.validate(Configuration.java:1332)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1835)
  at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
  ... 31 more
  </code></pre>
  
  <p>By the way, I added these dependencies before starting my project :</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
      &lt;version&gt;${org.springframework-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;${org.springframework-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;3.2.2.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-commons-annotations&lt;/artifactId&gt;
      &lt;version&gt;3.2.0.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;3.6.0.FINAL&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;4.1.0.FINAL&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
      &lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-jpa-2.0-api&lt;/artifactId&gt;
      &lt;version&gt;1.0.0.FINAL&lt;/version&gt;
      &lt;/dependency&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.6&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>And finally, my applicationContext.xml looks like this:</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:tx="http://www.springframework.org/schema/tx"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"&gt;
  
  &lt;bean id="dao" class="org.gestion.infopanne.dao.FonctionsDAOimplem"&gt;  &lt;/bean&gt;
  &lt;bean id="metier" class="org.gestion.infopanne.metier.Fonctionsmetierimplem"&gt;
  &lt;property name="dao" ref="dao"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
  &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"&gt;   &lt;/property&gt;
  &lt;property name="url" value="jdbc:mysql://localhost:3306/panne"&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="persistenceUnitManager"  class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitMana ger"&gt;
  &lt;property name="persistenceXmlLocations"&gt;
  &lt;list&gt;
  
  &lt;value&gt;classpath*:META-INF/persistence.xml&lt;/value&gt;
  &lt;/list&gt;
  &lt;/property&gt;
  &lt;property name="defaultDataSource" ref="dataSource"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="entityManagerFactory"  class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
  &lt;property name="persistenceUnitManager" ref="persistenceUnitManager"&gt;    &lt;/property&gt;
  &lt;property name="persistenceUnitName" value="MY_P_U"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="transactionManager"  class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
  &lt;property name="entityManagerFactory" ref="entityManagerFactory"&gt;   &lt;/property&gt;
  &lt;/bean&gt;
  &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  &lt;context:annotation-config&gt;&lt;/context:annotation-config&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>    package org.gestion.infopanne.entities; 
      import java.util.Date; 
      import javax.persistence.DiscriminatorValue; 
      import javax.persistence.Entity; 
  
      @Entity 
      @DiscriminatorValue("simple") 
      public class simplemessage extends message{ 
  
      public simplemessage() { super(); } 
  
      public simplemessage(String materiel, String description,String genre, String date) 
  
      { super(materiel, description, genre, date); } 
  }
  </code></pre>
  
  <p>Message class:</p>
  
  <pre><code>package org.gestion.infopanne.entities;
  
  import java.io.Serializable;
  import java.util.Date;
  
  import javax.persistence.DiscriminatorColumn;
  import javax.persistence.DiscriminatorType;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Inheritance;
  import javax.persistence.InheritanceType;
  import javax.persistence.JoinColumn;
  import javax.persistence.ManyToOne;
  @Entity
  @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
  @DiscriminatorColumn(name="genre",discriminatorType=DiscriminatorType.STRING)
  public class message implements Serializable {
  @Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  private int idm;
  private String materiel;
  private String description;
  private String genre;
  private String date;
  @ManyToOne
  @JoinColumn(name="idm")
  private utilisateur user;
  public message() {
      super();
      // TODO Auto-generated constructor stub
  }
  public message(String materiel, String description,String genre, String date) {
      super();
      this.materiel = materiel;
      this.description = description;
      this.genre = genre;
      this.date = date;
  }
  public int getId() {
      return idm;
  }
  public void setId(int id) {
      this.idm = id;
  }
  public String getMateriel() {
      return materiel;
  }
  public void setMateriel(String materiel) {
      this.materiel = materiel;
  }
  public String getDescription() {
      return description;
  }
  public void setDescription(String description) {
      this.description = description;
  }
  public String getGenre() {
      return genre;
  }
  public void setGenre(String genre) {
      this.genre = genre;
  }
  public String getDate() {
      return date;
  }
  public void setDate(String date) {
      this.date = date;
  }
  public utilisateur getUser() {
      return user;
  }
  public void setUser(utilisateur user) {
      this.user = user;
  }
  
  }
  </code></pre>