0

I am trying to make use of the spring-retry library in my batch job and on adding the @EnableRetry annotation to my @Configuration as documentation suggests my application is now failing because it appears a spring-batch library bean which is being @Autowired is being proxied.

@Configuration
@EnableBatchProcessing
@EnableRetry
@Import({SpringBatchConfiguration.class, School192ClientConfiguration.class })
public class SchoolJobConfiguration { .. }

Exception:

Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'jobRegistry' is expected to be of type 'org.springframework.batch.core.configuration.JobRegistry' but was actually of type 'com.sun.proxy.$Proxy130'

I have added the following to a separate class:

@Retryable(value = School192ClientException.class, maxAttempts = 3, backoff = @Backoff(delay = 2000))
@Override
protected void doReadPage() {

My question is why is this bean (jobRegistry) being proxied? (I don't have much experience with AOP).

I am using spring-boot version 1.5.3.RELEASE.

Bond - Java Bond
  • 3,972
  • 6
  • 36
  • 59
dapperwaterbuffalo
  • 2,672
  • 5
  • 35
  • 48
  • Where is that bean configured? – Michael Minella Oct 02 '17 at 17:01
  • Spring Boot is auto configuring that for me. Upgrading my version of spring-retry to 1.1.5.RELEASE and spring-boot to 1.5.7.RELEASE seems to rid me of the problem. (though I am no better off understanding the original cause) – dapperwaterbuffalo Oct 04 '17 at 11:05
  • The likely problem was the combination of using java proxies and cglib proxies which is why I was asking where it was configured. – Michael Minella Oct 04 '17 at 15:30
  • I am using spring boot and the spring boot batch starter, which is wiring all that for me. I couldn’t see any annotations which I would expect to make that class a candidate for proxying but maybe thats my lack of understanding? – dapperwaterbuffalo Oct 04 '17 at 16:31
  • how looks SpringBatchConfiguration class? – milbr Oct 05 '17 at 10:17

0 Answers0