Hi everyone!
First of all, sorry for my english, I'm french.
I did Mark Fisher's tutorial 'Getting Started With JPA in Spring 2.0' without any problem.
I tried to do the same thing with the hibernate implementation of JPA and that doesn't work anymore.
I only changed the libraries and the application-context.xml file :
Here is my persistence.xml :Code:<bean id="restaurantDao" class="blog.jpa.dao.JpaRestaurantDao"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="persistenceUnitName" value="Spring" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="database" value="MYSQL"/> <property name="showSql" value="true"/> <property name="generateDdl" value="true"/> <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect"/> </bean> </property> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost/test"/> <property name="username" value="Beegees"/> <property name="password" value="***"/> </bean> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> <property name="dataSource" ref="dataSource"/> </bean> </beans>
And when i run the Junit tests, I get this error :Code:<persistence-unit name="Spring" transaction-type="RESOURCE_LOCAL"/>
If you want the complete trace, I can post it later.Code:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'restaurantDao' while setting bean property 'restaurantDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restaurantDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(Ljavax/persistence/spi/PersistenceUnitInfo;Ljava/util/Map;)Ljavax/persistence/EntityManagerFactory;
Could you help me please?
Thanks in advance
Beegees


Reply With Quote