Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-14302

Camel-spring: No longer possible to invoke static method of non-spring bean

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.0.1, 3.1.0
    • Component/s: camel-spring
    • Labels:
    • Estimated Complexity:
      Unknown

      Description

      This route worked fine in Camel 2.24.2 (and Spring Boot 2.2.1.RELEASE):

      @Component
      public class UuidRoute extends RouteBuilder {
      
          @Override
          public void configure() throws Exception {
              from("seda:in")
                  .setHeader("CorrelationId", method(java.util.UUID.class, "randomUUID"))
                  .to("mock:out");
          }
      }
      

      but fails with Camel 3.0.0 (and Spring Boot 2.2.1.RELEASE (also with Spring Boot 2.2.2.RELEASE)) when the route is used:

      2019-12-15 14:00:09.453  WARN 17476 --- [ #1 - seda://in] o.a.camel.component.seda.SedaConsumer    : Error processing exchange. Exchange[]. Caused by: [org.springframework.beans.factory.UnsatisfiedDependencyException - Error creating bean with name 'java.util.UUID': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'byte[]' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}]
      
      org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'java.util.UUID': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'byte[]' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:787) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:226) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:353) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.apache.camel.spring.spi.SpringInjector.newInstance(SpringInjector.java:64) ~[camel-spring-3.0.0.jar:3.0.0]
      	at org.apache.camel.spring.spi.SpringInjector.newInstance(SpringInjector.java:41) ~[camel-spring-3.0.0.jar:3.0.0]
      	at org.apache.camel.component.bean.ConstantTypeBeanHolder.getBean(ConstantTypeBeanHolder.java:65) ~[camel-bean-3.0.0.jar:3.0.0]
      	at org.apache.camel.component.bean.AbstractBeanProcessor.process(AbstractBeanProcessor.java:71) ~[camel-bean-3.0.0.jar:3.0.0]
      	at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:78) ~[camel-base-3.0.0.jar:3.0.0]
      	at org.apache.camel.support.AsyncProcessorSupport.process(AsyncProcessorSupport.java:40) ~[camel-support-3.0.0.jar:3.0.0]
      	at org.apache.camel.language.bean.BeanExpression.invokeBean(BeanExpression.java:297) ~[camel-bean-3.0.0.jar:3.0.0]
      	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:159) ~[camel-bean-3.0.0.jar:3.0.0]
      	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:171) ~[camel-bean-3.0.0.jar:3.0.0]
      	at org.apache.camel.processor.SetHeaderProcessor.process(SetHeaderProcessor.java:46) ~[camel-base-3.0.0.jar:3.0.0]
      	at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryState.run(RedeliveryErrorHandler.java:476) ~[camel-base-3.0.0.jar:3.0.0]
      	at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:185) ~[camel-base-3.0.0.jar:3.0.0]
      	at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59) ~[camel-base-3.0.0.jar:3.0.0]
      	at org.apache.camel.processor.Pipeline.process(Pipeline.java:87) ~[camel-base-3.0.0.jar:3.0.0]
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:228) ~[camel-base-3.0.0.jar:3.0.0]
      	at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:266) ~[camel-seda-3.0.0.jar:3.0.0]
      	at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:180) ~[camel-seda-3.0.0.jar:3.0.0]
      	at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:125) ~[camel-seda-3.0.0.jar:3.0.0]
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
      	at java.base/java.lang.Thread.run(Thread.java:831) ~[na:na]
      Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'byte[]' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1695) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1253) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:874) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:778) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      	... 27 common frames omitted
      

      Test to allow reproduction:

      @RunWith(CamelSpringBootRunner.class)
      @SpringBootTest
      public class InvokeBeanNotCreatableBySpring {
      
          @Produce(uri = "seda:in")
          private ProducerTemplate template;
          @EndpointInject(uri = "mock:out")
          private MockEndpoint mockOut;
      
          @Test
          public void test() throws Exception {
              mockOut.expectedMessageCount(1);
              template.sendBody("");
              mockOut.assertIsSatisfied();
          }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              pascalschumacher Pascal Schumacher
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: