Reputation: 1255
After I added @Retryable
annotation to my spring-data-cassandra repository interface, now the application fails to start with following exception:
APPLICATION FAILED TO START
The bean 'airingDao' could not be injected as a 'my.dao.AiringDao' because it is a JDK dynamic proxy that implements:
org.springframework.data.cassandra.repository.CassandraRepository
Action:
Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.
Added proxyTargetClass=true
to @EnableAsync
and @EnableCaching
, even to @EnableRetry(proxyTargetClass = true)
@EnableAspectJAutoProxy(proxyTargetClass = true)
But still doesn't work.
After I remove the @Retryable
, every thing works fine.
Checked the code, without @Retryable
, in org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(String, Class<T>, Object[], boolean)
bean.getClass().getInterfaces()
(java.lang.Class<T>[]) [interface my.dao.AiringDao, interface
org.springframework.data.repository.Repository, interface
org.springframework.transaction.interceptor.TransactionalProxy, interface
org.springframework.aop.framework.Advised, interface
org.springframework.core.DecoratingProxy]
So requiredType.isAssignableFrom(bean.getClass())
is true
But after added @Retryable
:
bean.getClass().getInterfaces()
(java.lang.Class<T>[]) [interface
org.springframework.retry.interceptor.Retryable, interface
org.springframework.aop.SpringProxy, interface
org.springframework.aop.framework.Advised, interface
org.springframework.core.DecoratingProxy]
So now requiredType.isAssignableFrom(bean.getClass()))
is false
and getTypeConverter().convertIfNecessary(bean, requiredType)
throws the exception.
Could anyone please help or provide some clue how to troubleshoot it? Thanks for your help.
Upvotes: 4
Views: 3683
Reputation: 121
Here is a workaround provided. I raised an issue for this in Spring-Retry GitHub.
Upvotes: 2
Reputation: 81907
Don't know Spring Retry, and haven't checked in detail, but I suspect, that there is no integration between Spring Data and Spring Retry yet. If this is true, you have two approaches available to you:
Open an issue on Spring Data or Spring Retry to get the integration implemented.
Introduce a separate layer for you @Retry
which you then let delegate to your Spring Data repositories.
Of course those approaches aren't mutual exclusive.
Upvotes: 4