mkhudyakov commented on issue #1205:
URL: 
https://github.com/apache/camel-kamelets/issues/1205#issuecomment-1350194783

   Thank you @oscerd
   
   Could you provide an example of dependency defined through the Kamelet, so 
that beans and processors are automatically bound to the registry?
   
   1. I have an example of an application
   ```
           final KameletMain main = new KameletMain();
           main.configure().setBasePackageScan("com.apache.kamelet.poc");
   ```
   and a `application.properties`
   ```
   camel.component.kamelet.location = 
classpath:/kamelets,github:apache:camel-kamelets/kamelets
   camel.main.routes-include-pattern = classpath:camel/*
   camel.main.routes-reload-enabled = true
   camel.main.routes-reload-directory = src/main/resources
   camel.main.routes-reload-pattern = camel/*.yaml
   camel.main.shutdown-timeout = 5
   camel.main.lightweight = false
   
   camel.main.autoConfigurationEnabled=true
   camel.main.autoConfigurationEnvironmentVariablesEnabled=true
   camel.main.autowiredEnabled=true
   camel.main.basePackageScanEnabled=true
   ```
   The application defines the route- `camel/application-route.yaml`
   ```
   - route:
       id: "example"
       from:
         uri: "kamelet:example-source?topic=kafka_topic"
         steps:
           - log: "${body}"
   ```
   2. The `kamelet:example-source` is defined in separate dependency 
(classpath-based lookup above allows application to see it)
   ```
   apiVersion: camel.apache.org/v1alpha1
   kind: Kamelet
   metadata:
     name: example-source
     annotations:
       camel.apache.org/kamelet.support.level: "Stable"
       ...
   spec:
     definition:
        ...
     types:
       out:
         mediaType: text/plain
     dependencies:
       - "camel:kamelet"
       - "camel:core"
       - "camel:kafka"
       - "mvn:com.apache.kamelet.poc:kamelet-poc-processors:1.0.0-SNAPSHOT"
     template:
       from:
         uri: "kafka:{{topic}}"
         parameters:
           brokers: "{{?bootstrapServers}}"
           groupId: "{{?consumerGroup}}"
           autoCommitEnable: "{{autoCommitEnable}}"
         steps:
           - bean: "customProcessor"
           - to: "kamelet:sink"
   ```
   3. `kamelet-poc-processors` module defines bean & configuration
   ```
   @Configuration
   public class CustomConfiguration implements CamelConfiguration {
   
       @BindToRegistry
       public CustomProcessor customProcessor() {
           return new CustomProcessor();
       }
   ...
   public class CustomProcessor {
       public void handle(Exchange exchange) throws Exception {
       ...
   
   ```
   
   `KameletMain` pulls dependencies indeed, but then fails with
   ```
   Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in 
the registry for: customProcessor
        at 
org.apache.camel.component.bean.RegistryBean.doGetBean(RegistryBean.java:134)
        at 
org.apache.camel.component.bean.RegistryBean.getBean(RegistryBean.java:102)
        at 
org.apache.camel.component.bean.RegistryBean.createCacheHolder(RegistryBean.java:95)
   ```
   
   However, once we add 
`com.apache.kamelet.poc:kamelet-poc-processors:1.0.0-SNAPSHOT` dependency to 
application's classpath, the error goes away.
   
   How can such a problem be fixed, so that dependency is defined through the 
Kamelet? I will be glad to create a pull request in case such an issue can be 
resolved


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to