[ 
https://issues.apache.org/jira/browse/CAMEL-23652?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen reopened CAMEL-23652:
---------------------------------

> [kamelet] Bean is not registered
> --------------------------------
>
>                 Key: CAMEL-23652
>                 URL: https://issues.apache.org/jira/browse/CAMEL-23652
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-kamelet
>    Affects Versions: 4.20.0
>            Reporter: Raymond
>            Priority: Minor
>         Attachments: routetemplate-xml.zip
>
>
> I like to use the following Kamelet:
> [https://github.com/apache/camel-kamelets/blob/main/kamelets/counter-source.kamelet.yaml]
> I slightly altered the Kamelet route to this:
> {code:java}
> template:
>   beans:
>     - name: counter
>       type: java.util.concurrent.atomic.AtomicInteger
>       constructors:
>         "0": "{{start}}"
>   from:
>     uri: timer:counter
>     parameters:
>       period: "{{period}}"
>       repeatCount: "{{?numbers}}"
>     steps:
>       - bean:
>           ref: "{{counter}}"
>           method: getAndIncrement
>       - setHeader:
>           name: "Content-Type"
>           constant: "text/plain"
>       - to: "{{out}}" {code}
> However when I call this the bean is not recognized, and a property is 
> expected. This is the error I see:
> {code:java}
> Failed to create route: 
> 69b3f52efbdb4c0011000147-7cee7a5b-d34c-450e-a8d0-02972b6ad07c at: >>> 
> Bean[ref:{{counter}} method:getAndIncrement] <<< in route: 
> Route(69b3f52efbdb4c0011000147-7cee7a5b-d34c-450e-a8d0-02972... because: 
> Property with key [counter] not found in properties from text: {{counter}}" 
> {code}
> I loaded the Kamelets like this:
> {code:java}
> public void setRouteTemplates() {
>     List<String> resourceNames = getKamelets();
>     RoutesLoader routesLoader = PluginHelper.getRoutesLoader(context);
>     for (String resourceName : resourceNames) {
>         Resource resource = 
> ResourceHelper.resolveResource(context,"classpath:kamelets/" + resourceName);
>         try {
>             routesLoader.loadRoutes(resource);
>         } catch (Exception e) {
>             log.warn("Could not load Kamelet: {}. Reason: {}", resourceName, 
> e.getMessage());
>         }
>     }
> } {code}
> I have around 200 Kamelets, and they load and function correctly. The only 
> thing that have issues is with the dynamically registered beans that locally 
> scoped with the Kamelet. Registering the bean programmatically, and then 
> referencing it (both hardcoded or with a property) works fine. 
> Is this because they are loaded throught the routesLoader (both the Kamelet, 
> as the templatedRoute)? Is this bug or I am missing something?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to