|
From: Thomas R. <tho...@tr...> - 2007-06-07 11:43:44
|
Magnus,
Don't think anything has changed recently. I think the error message
"Specified resource type [ javax.persistence.EntityManager] is not
assignable to method parameter type [interface
org.hibernate.ejb.HibernateEntityManager" points to the problem. Your
@PersistenceContext annotated setter should take a
javax.persistence.EntityManager and if you need to cast that to a
HibernateEntityManager then you wold need to do that in your code.
Thomas
Magnus Heino wrote:
>
> Hi.
>
> Has something changes recently that cause injection of implementation
> specific entitymanagers using PersistenceAnnotationBeanPostProcessor
> to fail?
>
> This used to work in 2.0.4 afaik. Then we started a migration to
> Oracle Toplink 11g preview, upgrades spring, and started getting these
> errors. I thoght it was connected to toplink, removed
> PersistenceAnnotationBeanPostProcessor and used normal setter
> injection. But now I'm back in the hibernate branch, upgrade spring to
> 2.1-m2 and got these errors once again...
>
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'processAssembler' defined in file
> [C:\Data\agtr\jboss-4.0.5.GA\server\default\.\tmp\deploy\tmp56715fr-app-exp.war\WEB-INF\classes\META-INF\spring-config\fr\assembler.xml
> ]: Cannot resolve reference to bean 'processRepository' while setting
> bean property 'processRepository'; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'processRepository' defined in file
> [C:\Data\agtr\jboss-
> 4.0.5.GA\server\default\.\tmp\deploy\tmp56715fr-app-exp.war\WEB-INF\classes\META-INF\spring-config\fr\dataAccess.xml]:
> Initialization of bean failed; nested exception is
> java.lang.IllegalStateException: Specified resource type [
> javax.persistence.EntityManager] is not assignable to method parameter
> type [interface org.hibernate.ejb.HibernateEntityManager]
>
> processRepository contains:
>
> private HibernateEntityManager entityManager;
>
> @Override
> protected HibernateEntityManager getEntityManager() {
> return this.entityManager;
> }
>
> @Override
> @PersistenceContext
> public void setEntityManager(HibernateEntityManager entityManager) {
> this.entityManager = entityManager;
> }
>
> Spring config:
>
> <bean id="persistenceUnitManager"
> class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager
> ">
> <property name="persistenceXmlLocations">
> <list>
> <value>classpath:META-INF/persistence.xml</value>
> </list>
> </property>
> <property name="defaultDataSource" ref="dataSource"/>
> </bean>
>
> <bean id="entityManagerFactory"
> class="
> org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
> <property name="persistenceUnitManager"
> ref="persistenceUnitManager"/>
> <property name="jpaVendorAdapter">
> <bean
>
> class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
> <property name="database" value="ORACLE"/>
> <property name="generateDdl" value="false"/>
> <property name="showSql" value="true"/>
> </bean>
> </property>
> <property name="jpaProperties">
> <props>
> <prop key="hibernate.dialect">
> se.lantmateriet.hibernate.dialect.OracleSpatialDialect</prop>
> <prop key="hibernate.hbm2ddl.auto">validate</prop>
> </props>
> </property>
> </bean>
>
> <bean id="entityManager"
> class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
> <property name="entityManagerFactory"
> ref="entityManagerFactory"/>
> </bean>
>
> <bean id="processRepository"
> class="se.lantmateriet.elips.poc.fr.persistence.HibernateJpaProcessRepository"/>
>
> <bean
>
> class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor
> "/>
> --
>
> /Magnus Heino
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ------------------------------------------------------------------------
>
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
|