I have some trouble with BeanNameAutoProxyCreator.
I have a lot of class with the same transactional methods. So i use BeanNameAutoProxyCreator to wrap them in a completely identical fashion.
See:
But when i inject one of these transactional beans in another bean:Code:<!-- define transaction interceptor --> <bean id="txInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager"><ref bean="transactionManager"/></property> <property name="transactionAttributeSource"><ref bean="txAttributes"/></property> </bean> <!-- Define transactional methods (NameMatchTransactionAttributeSource applies specific attributes to methods that match to a pattern) --> <bean id="txAttributes" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource"> <property name="properties"><value>add*=PROPAGATION_REQUIRED update*=PROPAGATION_REQUIRED delete*=PROPAGATION_REQUIRED </value> </property> </bean> <!-- Define transactional beans (thanks Autoproxy) i.e. every mappers --> <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="interceptorNames"><value>txInterceptor</value></property> <property name="beanNames"><value>*Mapper</value></property> </bean>
I have this exception :Code:<bean id="userRepository" class="com.pm.core.domain.user.UserRepositoryImpl" singleton="true" dependency-check="objects"> <constructor-arg index="0"><ref bean="userMapper"/></constructor-arg> </bean>
Spring manuel says that "when BeanNameAutoProxyCreator postprocesses the target object and create the proxy, it causes the proxy to be inserted into the Application context under the name of the original bean"Error creating bean with name 'userRepository' defined in class path resource [coreContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy0] to required type [com.pm.core.data.user.UserMapper]
So how can i get the original bean and not his proxy ? And will transaction works ?
thanks
Arnaud


Reply With Quote