doru1004 commented on issue #1579:
URL: https://github.com/apache/camel-k/issues/1579#issuecomment-651809029


   What I am trying to do is have a working application using Camel K. I have 
managed to do a Java only application. What I would now want to do is rewrite 
the Camel integration in Yaml.
   
   Some initial features that I want to exercise are:
   1. sending HTTP requests to some third-party service and getting a response
   2. have a custom processor to process that response
   
   I would like to do this from YAML to see how that can be done using YAML 
instead of Camel Java code.
   
   
   In this particular issue I am trying to handle point 2.
   
   It seems that the problematic part is being able to include processor part.
   
   This is my call right now after you telling me that the --property is not 
required:
   
   ```
   kamel run --name=test routes.yaml RegistryConfigurer.java --dev
   ```
   
   routes contains this:
   
   ```
   - from:
       uri: "timer:clock"
       parameters:
         period: "1000"
       steps:
         - set-body:
           constant: "foo"
         - process:
           ref: "myProcessor"
         - to: log:info
   ```
   
   Registry configurer file contains this:
   
   ```
   ... 
   class MyProcessor implements Processor {
     void public process(...) {
        ... 
     }
   }
   
   public class RegistryConfigurer {
       @BindToRegistry
       public MyProcessor myProcessor() {
           return new MyProcessor();
       }
   }
   ```
   
   After eliminating the `--property` flag from the kamel run CLI, I get the 
following error. Can this error be fixed if I publish my class in a maven repo?
   
   ```
   [1] 2020-06-30 13:39:36.150 INFO  [main] ApplicationRuntime - Listener 
org.apache.camel.k.listener.RoutesConfigurer@51972dc7 executed in phase 
ConfigureRoutes
   [1] Exception in thread "main" java.lang.IllegalStateException: 
com.fasterxml.jackson.databind.JsonMappingException: Step should not have more 
tha one child (through reference chain: 
org.apache.camel.k.loader.yaml.parser.FromStepParser$FromStepDefinition["steps"]->java.util.ArrayList[0])
   [1]  at 
org.apache.camel.k.loader.yaml.spi.StepParser$Context.node(StepParser.java:83)
   [1]  at 
org.apache.camel.k.loader.yaml.parser.FromStepParser.toStartProcessor(FromStepParser.java:38)
   [1]  at 
org.apache.camel.k.loader.yaml.spi.StartStepParser.invoke(StartStepParser.java:29)
   [1]  at 
org.apache.camel.k.loader.yaml.YamlSourceLoader$1.configure(YamlSourceLoader.java:93)
   [1]  at 
org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:473)
   [1]  at 
org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:421)
   [1]  at 
org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:401)
   [1]  at 
org.apache.camel.impl.engine.AbstractCamelContext.addRoutes(AbstractCamelContext.java:1190)
   [1]  at 
org.apache.camel.main.RoutesConfigurer.configureRoutes(RoutesConfigurer.java:92)
   [1]  at 
org.apache.camel.main.BaseMainSupport.configureRoutes(BaseMainSupport.java:552)
   [1]  at 
org.apache.camel.main.BaseMainSupport.postProcessCamelContext(BaseMainSupport.java:572)
   [1]  at 
org.apache.camel.main.BaseMainSupport.initCamelContext(BaseMainSupport.java:379)
   [1]  at 
org.apache.camel.k.main.ApplicationRuntime$MainAdapter.doInit(ApplicationRuntime.java:197)
   [1]  at 
org.apache.camel.support.service.BaseService.init(BaseService.java:83)
   [1]  at org.apache.camel.main.MainSupport.run(MainSupport.java:79)
   [1]  at 
org.apache.camel.k.main.ApplicationRuntime.run(ApplicationRuntime.java:70)
   [1]  at org.apache.camel.k.main.Application.main(Application.java:42)
   [1] Caused by: com.fasterxml.jackson.databind.JsonMappingException: Step 
should not have more tha one child (through reference chain: 
org.apache.camel.k.loader.yaml.parser.FromStepParser$FromStepDefinition["steps"]->java.util.ArrayList[0])
   [1]  at 
com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:397)
   [1]  at 
com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:368)
   [1]  at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
   [1]  at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
   [1]  at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
   [1]  at 
com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
   [1]  at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
   [1]  at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
   [1]  at 
com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1719)
   [1]  at 
com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1350)
   [1]  at 
org.apache.camel.k.loader.yaml.spi.StepParser$Context.node(StepParser.java:81)
   [1]  ... 16 more
   [1] Caused by: java.lang.IllegalStateException: Step should not have more 
tha one child
   [1]  at 
org.apache.camel.k.loader.yaml.model.Step$Deserializer.deserialize(Step.java:52)
   [1]  at 
org.apache.camel.k.loader.yaml.model.Step$Deserializer.deserialize(Step.java:38)
   [1]  at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
   ```


----------------------------------------------------------------
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.

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


Reply via email to