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

camel-core - Dependency injection for @BeanInject for private fields

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 4.3.0
    • camel-jbang, camel-main
    • None
    • Unknown

    Description

      import org.apache.camel.Configuration;
      import org.apache.camel.spi.IdempotentRepository;
      import org.apache.camel.processor.idempotent.jdbc.JdbcMessageIdRepository;
      import org.apache.camel.BeanInject;
      import org.apache.camel.BindToRegistry;
      import javax.sql.DataSource;
      
      @Configuration
      public class Testidempotentrepository {
      
          @BeanInject 
          private DataSource dataSource;
      
          @BindToRegistry("Testidempotentrepository")
          public IdempotentRepository createIdempotentRegistry() {
              return new JdbcMessageIdRepository(dataSource, "some-key");
          }
      }
      

      Fails with

      Caused by: java.lang.IllegalArgumentException: Property 'dataSource' is required
      at org.springframework.jdbc.datasource.DataSourceTransactionManager.afterPropertiesSet(DataSourceTransactionManager.java:235)
      at org.springframework.jdbc.datasource.DataSourceTransactionManager.<init>(DataSourceTransactionManager.java:146)
      at org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository.createTransactionTemplate(AbstractJdbcMessageIdRepository.java:116)
      at org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository.<init>(AbstractJdbcMessageIdRepository.java:77)
      at org.apache.camel.processor.idempotent.jdbc.JdbcMessageIdRepository.<init>(JdbcMessageIdRepository.java:61)
      at Testidempotentrepository.createIdempotentRegistry(Testidempotentrepository.java:16)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      at org.apache.camel.support.ObjectHelper.invokeMethod(ObjectHelper.java:425)

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              davsclaus Claus Ibsen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: