I setted up caching based on Spring modules with EHCache. Caching works well, but flushing fails in my test (AbstractJpaTests):
Cannot convert value of type [$Proxy29] to required type [org.fao.fenix.persistence.perspective.TableDao] for property 'tableDao': no matching editors or conversion strategy found
when I use
@CacheFlush(modelId = "fenixCacheFlushing")
My TableDao looks like this:
Code:@Repository @Transactional public class TableDao { @PersistenceContext private EntityManager entityManager;
This is the full stacktrace:
This is my configuration:Code:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pog' defined in class path resource [applicationContext-test.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy29] to required type [org.fao.fenix.persistence.perspective.TableDao] for property 'tableDao'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy29] to required type [org.fao.fenix.persistence.perspective.TableDao] for property 'tableDao': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:230) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:228) at junit.framework.TestSuite.run(TestSuite.java:223) at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy29] to required type [org.fao.fenix.persistence.perspective.TableDao] for property 'tableDao'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy29] to required type [org.fao.fenix.persistence.perspective.TableDao] for property 'tableDao': no matching editors or conversion strategy found at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1287) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1248) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470) ... 29 more Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy29] to required type [org.fao.fenix.persistence.perspective.TableDao] for property 'tableDao': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:219) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386) ... 33 more
Code:<bean id="autoproxy" class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" /> <!-- The created cache manager is an instance of net.sf.ehcache.CacheManager --> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"></bean> <bean id="cacheProviderFacade" class="org.springmodules.cache.provider.ehcache.EhCacheFacade"> <property name="cacheManager" ref="cacheManager" /> </bean> <bean id="cachingAttributeSource" class="org.springmodules.cache.annotations.AnnotationCachingAttributeSource"> </bean> <bean id="cachingInterceptor" class="org.springmodules.cache.interceptor.caching.MetadataCachingInterceptor"> <property name="cacheProviderFacade" ref="cacheProviderFacade" /> <property name="cachingAttributeSource" ref="cachingAttributeSource" /> <property name="cachingModels"> <props> <prop key="fenixCaching">cacheName=fenixCache</prop> </props> </property> </bean> <bean id="cachingAttributeSourceAdvisor" class="org.springmodules.cache.interceptor.caching.CachingAttributeSourceAdvisor"> <constructor-arg ref="cachingInterceptor" /> </bean> <bean id="flushingAttributeSource" class="org.springmodules.cache.annotations.AnnotationFlushingAttributeSource"> </bean> <bean id="flushingInterceptor" class="org.springmodules.cache.interceptor.flush.MetadataFlushingInterceptor"> <property name="cacheProviderFacade" ref="cacheProviderFacade" /> <property name="flushingAttributeSource" ref="flushingAttributeSource" /> <property name="flushingModels"> <props> <prop key="fenixCacheFlushing">cacheNames=fenixCache</prop> </props> </property> </bean> <bean id="flushingAttributeSourceAdvisor" class="org.springmodules.cache.interceptor.flush.FlushingAttributeSourceAdvisor"> <constructor-arg ref="flushingInterceptor" /> </bean>
What am I doing wrong? Or is this just a bug in Spring or in Spring-modules?
I have the idea that TableDao is already proxied because of its @PersistenceContext. Is that a problem? TableDao does not have an interface. Could that be a problem?


