You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using spring-retry with JPA repositories, the JPA repo proxy is (incorrectly) wrapped in a proxy that only implements Retryable.
We get a strange error when trying to inject this bean:
The bean 'testRepository' could not be injected as a 'com.example.demo.TestRepository' because it is a JDK dynamic proxy that implements:
org.springframework.data.repository.CrudRepository
The logic here...
printer.printf("The bean '%s' could not be injected as a '%s' because it is a "
+ "JDK dynamic proxy that implements:%n", ex.getBeanName(), ex.getRequiredType().getName());
for (Class<?> requiredTypeInterface : ex.getRequiredType().getInterfaces()) {
printer.println("\t" + requiredTypeInterface.getName());
}
...simply appends the super-interface of TestRepository (CrudRepository) to the error message.
The actual exception message is:
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'testRepository' is expected to be of type 'com.example.demo.TestRepository' but was actually of type 'com.sun.proxy.$Proxy70'
$Proxy70 doesn't actually implement CrudRepository - only Retryable.
I believe the correct logic would be to use getActualType().getInterfaces() in the for loop.
The text was updated successfully, but these errors were encountered:
scottfrederick
changed the title
Misleading/Confusing Error Reported by BeanNotOfRequiredTypeFailureAnalyzer
Misleading type information reported by BeanNotOfRequiredTypeFailureAnalyzer
Jun 16, 2021
Related to spring-projects/spring-retry#214
When using spring-retry with JPA repositories, the JPA repo proxy is (incorrectly) wrapped in a proxy that only implements
Retryable
.We get a strange error when trying to inject this bean:
The logic here...
...simply appends the super-interface of
TestRepository
(CrudRepository
) to the error message.The actual exception message is:
$Proxy70
doesn't actually implementCrudRepository
- onlyRetryable
.I believe the correct logic would be to use
getActualType().getInterfaces()
in the for loop.The text was updated successfully, but these errors were encountered: