简体   繁体   中英

Error in startup application when using @ServiceActivator in Spring cloud Stream

I put @ServiceActivator to log all messages that gave error to kafka:

@ServiceActivator(inputChannel = "errorChannel")
public void handleErrors(final ErrorMessage in) {
    log.error("encountered exception" + em.toString());
}

and I'm also setting the errorChannelEnabled flag to true:

  cloud:
    stream:
      function:
        definition: consumeProfile
      bindings:
        #kafka producer
        produceProfile-out-0:
          binder: kafka
          destination: profile
          producer:
            use-native-encoding: true
            error-channel-enabled: true

the problem is when I'm uploading the application I'm getting this error log:

org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'profileListener.handleErrors.serviceActivator': Requested bean is currently in creation: Is there an unresolvable circular reference?
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:355) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:227) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1160) ~[spring-context-5.3.21.jar:5.3.21]
    at org.springframework.integration.monitor.IntegrationMBeanExporter.enhanceHandlerMonitor(IntegrationMBeanExporter.java:865) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
    at org.springframework.integration.monitor.IntegrationMBeanExporter.registerHandler(IntegrationMBeanExporter.java:695) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
    at org.springframework.integration.monitor.IntegrationMBeanExporter.postProcessAbstractEndpoint(IntegrationMBeanExporter.java:340) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
    at org.springframework.integration.monitor.IntegrationMBeanExporter.postProcessAfterInitialization(IntegrationMBeanExporter.java:324) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.postProcessMethodAndRegisterEndpointIfAny(MessagingAnnotationPostProcessor.java:257) ~[spring-integration-core-5.5.13.jar:5.5.13]
    at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.lambda$processAnnotationTypeOnMethod$1(MessagingAnnotationPostProcessor.java:215) ~[spring-integration-core-5.5.13.jar:5.5.13]
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
    at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.afterSingletonsInstantiated(MessagingAnnotationPostProcessor.java:136) ~[spring-integration-core-5.5.13.jar:5.5.13]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:974) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.21.jar:5.3.21]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.21.jar:5.3.21]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.1.jar:2.7.1]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.1.jar:2.7.1]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.1.jar:2.7.1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.1.jar:2.7.1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.1.jar:2.7.1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.1.jar:2.7.1]
    at com.github.victorsilva95.pocspringcloudstreamkafka.PocSpringCloudStreamKafkaApplication.main(PocSpringCloudStreamKafkaApplication.java:14) ~[main/:na]

my application does not crash because of this exception, but I wanted your help to understand the reason, thank you

Thank you for the sample.

This is a bug in the IntegrationMBeanExporter : we try to pull an endpoint bean at the moment it is created by the MessagingAnnotationPostProcessor .

So, please, raise a GH issue in the Spring Integration project and we will see what we can do.

Meanwhile as a workaround you can turn off JMX by respective Srping Boot property: spring.jmx.enabled=false . We have it auto-configured by default for Spring Integration regardless of Spring Boot default decision:

@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
protected static class IntegrationJmxConfiguration {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM