You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Chirag <ch...@gmail.com> on 2022/01/17 00:46:28 UTC

Using camel-main, xml route, referencing a java class as processor

Hello,
I have a scenario where I am using camel-main with XML Route and a Java
Class as a Processor.

It gives me following error:

Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
Failed to create route route1 at: >>>
process[ref:#class:org.myorg.camel.MyProcessor] <<< in route:
Route(route1)[From[timer://foo?fixedRate=true&period=60000] ... because of
No bean could be found in the registry for:
#class:org.myorg.camel.MyProcessor of type: org.apache.camel.Processor
        at
org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240)
        at
org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
        at
org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
        at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:868)
        at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:758)
        at
org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2861)
        at
org.apache.camel.support.service.BaseService.init(BaseService.java:83)
        at
org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2567)
        at
org.apache.camel.support.service.BaseService.start(BaseService.java:111)
        at
org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2586)
        at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247)
        at org.apache.camel.main.Main.doStart(Main.java:116)
        at
org.apache.camel.support.service.BaseService.start(BaseService.java:119)
        at org.apache.camel.main.MainSupport.run(MainSupport.java:69)
        at
org.apache.camel.main.MainCommandLineSupport.run(MainCommandLineSupport.java:174)
        at org.myorg.camel.MyMainApp.main(MyMainApp.java:21)
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
the registry for: #class:org.myorg.camel.MyProcessor of type:
org.apache.camel.Processor
        at
org.apache.camel.support.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:241)
        at
org.apache.camel.reifier.AbstractReifier.mandatoryLookup(AbstractReifier.java:145)
        at
org.apache.camel.reifier.ProcessReifier.createProcessor(ProcessReifier.java:40)
        at
org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:838)
        at
org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579)
        at
org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
        ... 15 more

Example Code is described:
https://github.com/chiragsanghavi/camel-experiments/tree/main/processor

Basically referring to processor using <process
ref="#class:org.myorg.camel.MyProcessor"/> in route directly as described
in
https://camel.apache.org/manual/processor.html#_referring_to_beans_using_class_syntax
.

But it doesn't seem to work.

Are there any other conditions to using #class ?


ચિરાગ/चिराग/Chirag
------------------------------------------
Sent from My Gmail Account

Re: Re[2]: Using camel-main, xml route, referencing a java class as processor

Posted by Chirag <ch...@gmail.com>.
Will try bean.

For now - I ended up doing a bind in the default registry.
I was mainly trying to find a low-code way of doing this.


ચિરાગ/चिराग/Chirag
------------------------------------------
Sent from My Gmail Account


On Tue, Jan 18, 2022 at 2:53 AM Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> In Camel 3.14 you can use bean instead of process to refer to the #class.
>
> On Tue, Jan 18, 2022 at 7:28 AM Claus Ibsen <cl...@gmail.com> wrote:
> >
> > Hi
> >
> > Yes this is not supported currently. I have created a JIRA and have a
> > fix for this:
> > https://issues.apache.org/jira/browse/CAMEL-17508
> >
> > On Tue, Jan 18, 2022 at 6:12 AM Chirag Sanghavi
> > <ch...@gmail.com> wrote:
> > >
> > > I am trying with Camel 3.14.0.
> > >
> > > While debugging I noticed that
> > >
> > > call gets to ProcessReifier.java
> > >
> > >   public Processor createProcessor() {
> > >          Processor answer =
> > > ((ProcessDefinition)this.definition).getProcessor();
> > >          if (answer == null) {
> > >
> > > ObjectHelper.notNull(((ProcessDefinition)this.definition).getRef(),
> > > "ref", this.definition);
> > >              answer =
> > >
> (Processor)this.mandatoryLookup(((ProcessDefinition)this.definition).getRef(),
> > > Processor.class);
> > >          }
> > >
> > > at that point - variables are as below:
> > >
> > > definition = {ProcessDefinition@3684}
> > > "process[ref:#class:org.myorg.camel.MyProcessor]"
> > >   ref = "#class:org.myorg.camel.MyProcessor"
> > >   processor = null
> > >   log = {Logger@3741}
> "Logger[org.apache.camel.model.ProcessDefinition]"
> > >   inheritErrorHandler = null
> > >   blocks = {LinkedList@3742}  size = 0
> > >   parent = {RouteDefinition@3358}
> > > "Route(route1)[From[timer://foo?fixedRate=true&period=60000] ->
> > > [SetBody[simple{Hello}],
> > > process[ref:#class:org.myorg.camel.MyProcessor], To[log:hello]]]"
> > >   interceptStrategies = {ArrayList@3743}  size = 0
> > >   index = 2
> > >   id = "process1"
> > >   customId = null
> > >   description = null
> > >
> > > ((ProcessDefinition)this.definition).getProcessor() , returns null and
> > > then it performs a lookup on registry.
> > >
> > > It never seemed to get to
> > > public Object lookupByName(String name) {
> > >          if (name != null && name.startsWith("#class:")) {
> > >              return this.createBean(name, Object.class);
> > >          } else {
> > >              return name != null && name.startsWith("#type:") ?
> > > this.lookupBean(name, Object.class) :
> > > this.getRegistry().lookupByName(name);
> > >          }
> > >      }
> > >
> > > if it may have - it may have identified that the class starts with
> > > #class: and needs to be bypassing registry.
> > >
> > > ------ Original Message ------
> > > From: "Claus Ibsen" <cl...@gmail.com>
> > > To: users@camel.apache.org
> > > Sent: 1/17/2022 4:38:12 AM
> > > Subject: Re: Using camel-main, xml route, referencing a java class as
> > > processor
> > >
> > > >What camel version do you use
> > > >
> > > >On Mon, Jan 17, 2022 at 9:27 AM Chirag <ch...@gmail.com>
> wrote:
> > > >>
> > > >>  Hello,
> > > >>  I have a scenario where I am using camel-main with XML Route and a
> Java
> > > >>  Class as a Processor.
> > > >>
> > > >>  It gives me following error:
> > > >>
> > > >>  Exception in thread "main"
> org.apache.camel.FailedToCreateRouteException:
> > > >>  Failed to create route route1 at: >>>
> > > >>  process[ref:#class:org.myorg.camel.MyProcessor] <<< in route:
> > > >>  Route(route1)[From[timer://foo?fixedRate=true&period=60000] ...
> because of
> > > >>  No bean could be found in the registry for:
> > > >>  #class:org.myorg.camel.MyProcessor of type:
> org.apache.camel.Processor
> > > >>          at
> > > >>
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240)
> > > >>          at
> > > >>
> org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
> > > >>          at
> > > >>
> org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
> > > >>          at
> > > >>
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:868)
> > > >>          at
> > > >>
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:758)
> > > >>          at
> > > >>
> org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2861)
> > > >>          at
> > > >>
> org.apache.camel.support.service.BaseService.init(BaseService.java:83)
> > > >>          at
> > > >>
> org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2567)
> > > >>          at
> > > >>
> org.apache.camel.support.service.BaseService.start(BaseService.java:111)
> > > >>          at
> > > >>
> org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2586)
> > > >>          at
> > > >>
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247)
> > > >>          at org.apache.camel.main.Main.doStart(Main.java:116)
> > > >>          at
> > > >>
> org.apache.camel.support.service.BaseService.start(BaseService.java:119)
> > > >>          at
> org.apache.camel.main.MainSupport.run(MainSupport.java:69)
> > > >>          at
> > > >>
> org.apache.camel.main.MainCommandLineSupport.run(MainCommandLineSupport.java:174)
> > > >>          at org.myorg.camel.MyMainApp.main(MyMainApp.java:21)
> > > >>  Caused by: org.apache.camel.NoSuchBeanException: No bean could be
> found in
> > > >>  the registry for: #class:org.myorg.camel.MyProcessor of type:
> > > >>  org.apache.camel.Processor
> > > >>          at
> > > >>
> org.apache.camel.support.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:241)
> > > >>          at
> > > >>
> org.apache.camel.reifier.AbstractReifier.mandatoryLookup(AbstractReifier.java:145)
> > > >>          at
> > > >>
> org.apache.camel.reifier.ProcessReifier.createProcessor(ProcessReifier.java:40)
> > > >>          at
> > > >>
> org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:838)
> > > >>          at
> > > >>
> org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579)
> > > >>          at
> > > >>
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
> > > >>          ... 15 more
> > > >>
> > > >>  Example Code is described:
> > > >>
> https://github.com/chiragsanghavi/camel-experiments/tree/main/processor
> > > >>
> > > >>  Basically referring to processor using <process
> > > >>  ref="#class:org.myorg.camel.MyProcessor"/> in route directly as
> described
> > > >>  in
> > > >>
> https://camel.apache.org/manual/processor.html#_referring_to_beans_using_class_syntax
> > > >>  .
> > > >>
> > > >>  But it doesn't seem to work.
> > > >>
> > > >>  Are there any other conditions to using #class ?
> > > >>
> > > >>
> > > >>  ચિરાગ/चिराग/Chirag
> > > >>  ------------------------------------------
> > > >>  Sent from My Gmail Account
> > > >
> > > >
> > > >
> > > >--
> > > >Claus Ibsen
> > > >-----------------
> > > >http://davsclaus.com @davsclaus
> > > >Camel in Action 2: https://www.manning.com/ibsen2
> > >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Re: Re[2]: Using camel-main, xml route, referencing a java class as processor

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

In Camel 3.14 you can use bean instead of process to refer to the #class.

On Tue, Jan 18, 2022 at 7:28 AM Claus Ibsen <cl...@gmail.com> wrote:
>
> Hi
>
> Yes this is not supported currently. I have created a JIRA and have a
> fix for this:
> https://issues.apache.org/jira/browse/CAMEL-17508
>
> On Tue, Jan 18, 2022 at 6:12 AM Chirag Sanghavi
> <ch...@gmail.com> wrote:
> >
> > I am trying with Camel 3.14.0.
> >
> > While debugging I noticed that
> >
> > call gets to ProcessReifier.java
> >
> >   public Processor createProcessor() {
> >          Processor answer =
> > ((ProcessDefinition)this.definition).getProcessor();
> >          if (answer == null) {
> >
> > ObjectHelper.notNull(((ProcessDefinition)this.definition).getRef(),
> > "ref", this.definition);
> >              answer =
> > (Processor)this.mandatoryLookup(((ProcessDefinition)this.definition).getRef(),
> > Processor.class);
> >          }
> >
> > at that point - variables are as below:
> >
> > definition = {ProcessDefinition@3684}
> > "process[ref:#class:org.myorg.camel.MyProcessor]"
> >   ref = "#class:org.myorg.camel.MyProcessor"
> >   processor = null
> >   log = {Logger@3741} "Logger[org.apache.camel.model.ProcessDefinition]"
> >   inheritErrorHandler = null
> >   blocks = {LinkedList@3742}  size = 0
> >   parent = {RouteDefinition@3358}
> > "Route(route1)[From[timer://foo?fixedRate=true&period=60000] ->
> > [SetBody[simple{Hello}],
> > process[ref:#class:org.myorg.camel.MyProcessor], To[log:hello]]]"
> >   interceptStrategies = {ArrayList@3743}  size = 0
> >   index = 2
> >   id = "process1"
> >   customId = null
> >   description = null
> >
> > ((ProcessDefinition)this.definition).getProcessor() , returns null and
> > then it performs a lookup on registry.
> >
> > It never seemed to get to
> > public Object lookupByName(String name) {
> >          if (name != null && name.startsWith("#class:")) {
> >              return this.createBean(name, Object.class);
> >          } else {
> >              return name != null && name.startsWith("#type:") ?
> > this.lookupBean(name, Object.class) :
> > this.getRegistry().lookupByName(name);
> >          }
> >      }
> >
> > if it may have - it may have identified that the class starts with
> > #class: and needs to be bypassing registry.
> >
> > ------ Original Message ------
> > From: "Claus Ibsen" <cl...@gmail.com>
> > To: users@camel.apache.org
> > Sent: 1/17/2022 4:38:12 AM
> > Subject: Re: Using camel-main, xml route, referencing a java class as
> > processor
> >
> > >What camel version do you use
> > >
> > >On Mon, Jan 17, 2022 at 9:27 AM Chirag <ch...@gmail.com> wrote:
> > >>
> > >>  Hello,
> > >>  I have a scenario where I am using camel-main with XML Route and a Java
> > >>  Class as a Processor.
> > >>
> > >>  It gives me following error:
> > >>
> > >>  Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
> > >>  Failed to create route route1 at: >>>
> > >>  process[ref:#class:org.myorg.camel.MyProcessor] <<< in route:
> > >>  Route(route1)[From[timer://foo?fixedRate=true&period=60000] ... because of
> > >>  No bean could be found in the registry for:
> > >>  #class:org.myorg.camel.MyProcessor of type: org.apache.camel.Processor
> > >>          at
> > >>  org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240)
> > >>          at
> > >>  org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
> > >>          at
> > >>  org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
> > >>          at
> > >>  org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:868)
> > >>          at
> > >>  org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:758)
> > >>          at
> > >>  org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2861)
> > >>          at
> > >>  org.apache.camel.support.service.BaseService.init(BaseService.java:83)
> > >>          at
> > >>  org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2567)
> > >>          at
> > >>  org.apache.camel.support.service.BaseService.start(BaseService.java:111)
> > >>          at
> > >>  org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2586)
> > >>          at
> > >>  org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247)
> > >>          at org.apache.camel.main.Main.doStart(Main.java:116)
> > >>          at
> > >>  org.apache.camel.support.service.BaseService.start(BaseService.java:119)
> > >>          at org.apache.camel.main.MainSupport.run(MainSupport.java:69)
> > >>          at
> > >>  org.apache.camel.main.MainCommandLineSupport.run(MainCommandLineSupport.java:174)
> > >>          at org.myorg.camel.MyMainApp.main(MyMainApp.java:21)
> > >>  Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
> > >>  the registry for: #class:org.myorg.camel.MyProcessor of type:
> > >>  org.apache.camel.Processor
> > >>          at
> > >>  org.apache.camel.support.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:241)
> > >>          at
> > >>  org.apache.camel.reifier.AbstractReifier.mandatoryLookup(AbstractReifier.java:145)
> > >>          at
> > >>  org.apache.camel.reifier.ProcessReifier.createProcessor(ProcessReifier.java:40)
> > >>          at
> > >>  org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:838)
> > >>          at
> > >>  org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579)
> > >>          at
> > >>  org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
> > >>          ... 15 more
> > >>
> > >>  Example Code is described:
> > >>https://github.com/chiragsanghavi/camel-experiments/tree/main/processor
> > >>
> > >>  Basically referring to processor using <process
> > >>  ref="#class:org.myorg.camel.MyProcessor"/> in route directly as described
> > >>  in
> > >>https://camel.apache.org/manual/processor.html#_referring_to_beans_using_class_syntax
> > >>  .
> > >>
> > >>  But it doesn't seem to work.
> > >>
> > >>  Are there any other conditions to using #class ?
> > >>
> > >>
> > >>  ચિરાગ/चिराग/Chirag
> > >>  ------------------------------------------
> > >>  Sent from My Gmail Account
> > >
> > >
> > >
> > >--
> > >Claus Ibsen
> > >-----------------
> > >http://davsclaus.com @davsclaus
> > >Camel in Action 2: https://www.manning.com/ibsen2
> >
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Re[2]: Using camel-main, xml route, referencing a java class as processor

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yes this is not supported currently. I have created a JIRA and have a
fix for this:
https://issues.apache.org/jira/browse/CAMEL-17508

On Tue, Jan 18, 2022 at 6:12 AM Chirag Sanghavi
<ch...@gmail.com> wrote:
>
> I am trying with Camel 3.14.0.
>
> While debugging I noticed that
>
> call gets to ProcessReifier.java
>
>   public Processor createProcessor() {
>          Processor answer =
> ((ProcessDefinition)this.definition).getProcessor();
>          if (answer == null) {
>
> ObjectHelper.notNull(((ProcessDefinition)this.definition).getRef(),
> "ref", this.definition);
>              answer =
> (Processor)this.mandatoryLookup(((ProcessDefinition)this.definition).getRef(),
> Processor.class);
>          }
>
> at that point - variables are as below:
>
> definition = {ProcessDefinition@3684}
> "process[ref:#class:org.myorg.camel.MyProcessor]"
>   ref = "#class:org.myorg.camel.MyProcessor"
>   processor = null
>   log = {Logger@3741} "Logger[org.apache.camel.model.ProcessDefinition]"
>   inheritErrorHandler = null
>   blocks = {LinkedList@3742}  size = 0
>   parent = {RouteDefinition@3358}
> "Route(route1)[From[timer://foo?fixedRate=true&period=60000] ->
> [SetBody[simple{Hello}],
> process[ref:#class:org.myorg.camel.MyProcessor], To[log:hello]]]"
>   interceptStrategies = {ArrayList@3743}  size = 0
>   index = 2
>   id = "process1"
>   customId = null
>   description = null
>
> ((ProcessDefinition)this.definition).getProcessor() , returns null and
> then it performs a lookup on registry.
>
> It never seemed to get to
> public Object lookupByName(String name) {
>          if (name != null && name.startsWith("#class:")) {
>              return this.createBean(name, Object.class);
>          } else {
>              return name != null && name.startsWith("#type:") ?
> this.lookupBean(name, Object.class) :
> this.getRegistry().lookupByName(name);
>          }
>      }
>
> if it may have - it may have identified that the class starts with
> #class: and needs to be bypassing registry.
>
> ------ Original Message ------
> From: "Claus Ibsen" <cl...@gmail.com>
> To: users@camel.apache.org
> Sent: 1/17/2022 4:38:12 AM
> Subject: Re: Using camel-main, xml route, referencing a java class as
> processor
>
> >What camel version do you use
> >
> >On Mon, Jan 17, 2022 at 9:27 AM Chirag <ch...@gmail.com> wrote:
> >>
> >>  Hello,
> >>  I have a scenario where I am using camel-main with XML Route and a Java
> >>  Class as a Processor.
> >>
> >>  It gives me following error:
> >>
> >>  Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
> >>  Failed to create route route1 at: >>>
> >>  process[ref:#class:org.myorg.camel.MyProcessor] <<< in route:
> >>  Route(route1)[From[timer://foo?fixedRate=true&period=60000] ... because of
> >>  No bean could be found in the registry for:
> >>  #class:org.myorg.camel.MyProcessor of type: org.apache.camel.Processor
> >>          at
> >>  org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240)
> >>          at
> >>  org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
> >>          at
> >>  org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
> >>          at
> >>  org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:868)
> >>          at
> >>  org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:758)
> >>          at
> >>  org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2861)
> >>          at
> >>  org.apache.camel.support.service.BaseService.init(BaseService.java:83)
> >>          at
> >>  org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2567)
> >>          at
> >>  org.apache.camel.support.service.BaseService.start(BaseService.java:111)
> >>          at
> >>  org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2586)
> >>          at
> >>  org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247)
> >>          at org.apache.camel.main.Main.doStart(Main.java:116)
> >>          at
> >>  org.apache.camel.support.service.BaseService.start(BaseService.java:119)
> >>          at org.apache.camel.main.MainSupport.run(MainSupport.java:69)
> >>          at
> >>  org.apache.camel.main.MainCommandLineSupport.run(MainCommandLineSupport.java:174)
> >>          at org.myorg.camel.MyMainApp.main(MyMainApp.java:21)
> >>  Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
> >>  the registry for: #class:org.myorg.camel.MyProcessor of type:
> >>  org.apache.camel.Processor
> >>          at
> >>  org.apache.camel.support.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:241)
> >>          at
> >>  org.apache.camel.reifier.AbstractReifier.mandatoryLookup(AbstractReifier.java:145)
> >>          at
> >>  org.apache.camel.reifier.ProcessReifier.createProcessor(ProcessReifier.java:40)
> >>          at
> >>  org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:838)
> >>          at
> >>  org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579)
> >>          at
> >>  org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
> >>          ... 15 more
> >>
> >>  Example Code is described:
> >>https://github.com/chiragsanghavi/camel-experiments/tree/main/processor
> >>
> >>  Basically referring to processor using <process
> >>  ref="#class:org.myorg.camel.MyProcessor"/> in route directly as described
> >>  in
> >>https://camel.apache.org/manual/processor.html#_referring_to_beans_using_class_syntax
> >>  .
> >>
> >>  But it doesn't seem to work.
> >>
> >>  Are there any other conditions to using #class ?
> >>
> >>
> >>  ચિરાગ/चिराग/Chirag
> >>  ------------------------------------------
> >>  Sent from My Gmail Account
> >
> >
> >
> >--
> >Claus Ibsen
> >-----------------
> >http://davsclaus.com @davsclaus
> >Camel in Action 2: https://www.manning.com/ibsen2
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re[2]: Using camel-main, xml route, referencing a java class as processor

Posted by Chirag Sanghavi <ch...@gmail.com>.
I am trying with Camel 3.14.0.

While debugging I noticed that

call gets to ProcessReifier.java

  public Processor createProcessor() {
         Processor answer = 
((ProcessDefinition)this.definition).getProcessor();
         if (answer == null) {
             
ObjectHelper.notNull(((ProcessDefinition)this.definition).getRef(), 
"ref", this.definition);
             answer = 
(Processor)this.mandatoryLookup(((ProcessDefinition)this.definition).getRef(), 
Processor.class);
         }

at that point - variables are as below:

definition = {ProcessDefinition@3684} 
"process[ref:#class:org.myorg.camel.MyProcessor]"
  ref = "#class:org.myorg.camel.MyProcessor"
  processor = null
  log = {Logger@3741} "Logger[org.apache.camel.model.ProcessDefinition]"
  inheritErrorHandler = null
  blocks = {LinkedList@3742}  size = 0
  parent = {RouteDefinition@3358} 
"Route(route1)[From[timer://foo?fixedRate=true&period=60000] -> 
[SetBody[simple{Hello}], 
process[ref:#class:org.myorg.camel.MyProcessor], To[log:hello]]]"
  interceptStrategies = {ArrayList@3743}  size = 0
  index = 2
  id = "process1"
  customId = null
  description = null

((ProcessDefinition)this.definition).getProcessor() , returns null and 
then it performs a lookup on registry.

It never seemed to get to
public Object lookupByName(String name) {
         if (name != null && name.startsWith("#class:")) {
             return this.createBean(name, Object.class);
         } else {
             return name != null && name.startsWith("#type:") ? 
this.lookupBean(name, Object.class) : 
this.getRegistry().lookupByName(name);
         }
     }

if it may have - it may have identified that the class starts with 
#class: and needs to be bypassing registry.

------ Original Message ------
From: "Claus Ibsen" <cl...@gmail.com>
To: users@camel.apache.org
Sent: 1/17/2022 4:38:12 AM
Subject: Re: Using camel-main, xml route, referencing a java class as 
processor

>What camel version do you use
>
>On Mon, Jan 17, 2022 at 9:27 AM Chirag <ch...@gmail.com> wrote:
>>
>>  Hello,
>>  I have a scenario where I am using camel-main with XML Route and a Java
>>  Class as a Processor.
>>
>>  It gives me following error:
>>
>>  Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
>>  Failed to create route route1 at: >>>
>>  process[ref:#class:org.myorg.camel.MyProcessor] <<< in route:
>>  Route(route1)[From[timer://foo?fixedRate=true&period=60000] ... because of
>>  No bean could be found in the registry for:
>>  #class:org.myorg.camel.MyProcessor of type: org.apache.camel.Processor
>>          at
>>  org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240)
>>          at
>>  org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
>>          at
>>  org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
>>          at
>>  org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:868)
>>          at
>>  org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:758)
>>          at
>>  org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2861)
>>          at
>>  org.apache.camel.support.service.BaseService.init(BaseService.java:83)
>>          at
>>  org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2567)
>>          at
>>  org.apache.camel.support.service.BaseService.start(BaseService.java:111)
>>          at
>>  org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2586)
>>          at
>>  org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247)
>>          at org.apache.camel.main.Main.doStart(Main.java:116)
>>          at
>>  org.apache.camel.support.service.BaseService.start(BaseService.java:119)
>>          at org.apache.camel.main.MainSupport.run(MainSupport.java:69)
>>          at
>>  org.apache.camel.main.MainCommandLineSupport.run(MainCommandLineSupport.java:174)
>>          at org.myorg.camel.MyMainApp.main(MyMainApp.java:21)
>>  Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
>>  the registry for: #class:org.myorg.camel.MyProcessor of type:
>>  org.apache.camel.Processor
>>          at
>>  org.apache.camel.support.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:241)
>>          at
>>  org.apache.camel.reifier.AbstractReifier.mandatoryLookup(AbstractReifier.java:145)
>>          at
>>  org.apache.camel.reifier.ProcessReifier.createProcessor(ProcessReifier.java:40)
>>          at
>>  org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:838)
>>          at
>>  org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579)
>>          at
>>  org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
>>          ... 15 more
>>
>>  Example Code is described:
>>https://github.com/chiragsanghavi/camel-experiments/tree/main/processor
>>
>>  Basically referring to processor using <process
>>  ref="#class:org.myorg.camel.MyProcessor"/> in route directly as described
>>  in
>>https://camel.apache.org/manual/processor.html#_referring_to_beans_using_class_syntax
>>  .
>>
>>  But it doesn't seem to work.
>>
>>  Are there any other conditions to using #class ?
>>
>>
>>  ચિરાગ/चिराग/Chirag
>>  ------------------------------------------
>>  Sent from My Gmail Account
>
>
>
>--
>Claus Ibsen
>-----------------
>http://davsclaus.com @davsclaus
>Camel in Action 2: https://www.manning.com/ibsen2


Re: Using camel-main, xml route, referencing a java class as processor

Posted by Claus Ibsen <cl...@gmail.com>.
What camel version do you use

On Mon, Jan 17, 2022 at 9:27 AM Chirag <ch...@gmail.com> wrote:
>
> Hello,
> I have a scenario where I am using camel-main with XML Route and a Java
> Class as a Processor.
>
> It gives me following error:
>
> Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
> Failed to create route route1 at: >>>
> process[ref:#class:org.myorg.camel.MyProcessor] <<< in route:
> Route(route1)[From[timer://foo?fixedRate=true&period=60000] ... because of
> No bean could be found in the registry for:
> #class:org.myorg.camel.MyProcessor of type: org.apache.camel.Processor
>         at
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240)
>         at
> org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
>         at
> org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:868)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:758)
>         at
> org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2861)
>         at
> org.apache.camel.support.service.BaseService.init(BaseService.java:83)
>         at
> org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2567)
>         at
> org.apache.camel.support.service.BaseService.start(BaseService.java:111)
>         at
> org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2586)
>         at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247)
>         at org.apache.camel.main.Main.doStart(Main.java:116)
>         at
> org.apache.camel.support.service.BaseService.start(BaseService.java:119)
>         at org.apache.camel.main.MainSupport.run(MainSupport.java:69)
>         at
> org.apache.camel.main.MainCommandLineSupport.run(MainCommandLineSupport.java:174)
>         at org.myorg.camel.MyMainApp.main(MyMainApp.java:21)
> Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
> the registry for: #class:org.myorg.camel.MyProcessor of type:
> org.apache.camel.Processor
>         at
> org.apache.camel.support.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:241)
>         at
> org.apache.camel.reifier.AbstractReifier.mandatoryLookup(AbstractReifier.java:145)
>         at
> org.apache.camel.reifier.ProcessReifier.createProcessor(ProcessReifier.java:40)
>         at
> org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:838)
>         at
> org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579)
>         at
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
>         ... 15 more
>
> Example Code is described:
> https://github.com/chiragsanghavi/camel-experiments/tree/main/processor
>
> Basically referring to processor using <process
> ref="#class:org.myorg.camel.MyProcessor"/> in route directly as described
> in
> https://camel.apache.org/manual/processor.html#_referring_to_beans_using_class_syntax
> .
>
> But it doesn't seem to work.
>
> Are there any other conditions to using #class ?
>
>
> ચિરાગ/चिराग/Chirag
> ------------------------------------------
> Sent from My Gmail Account



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Using camel-main, xml route, referencing a java class as processor

Posted by Chirag <ch...@gmail.com>.
I use Camel 3.14.0

I haven't figured out how to reply to thead using gmail so please bear with
me.

On Sun, Jan 16, 2022 at 7:46 PM Chirag <ch...@gmail.com> wrote:

> Hello,
> I have a scenario where I am using camel-main with XML Route and a Java
> Class as a Processor.
>
> It gives me following error:
>
> Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
> Failed to create route route1 at: >>>
> process[ref:#class:org.myorg.camel.MyProcessor] <<< in route:
> Route(route1)[From[timer://foo?fixedRate=true&period=60000] ... because of
> No bean could be found in the registry for:
> #class:org.myorg.camel.MyProcessor of type: org.apache.camel.Processor
>         at
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240)
>         at
> org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
>         at
> org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:868)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:758)
>         at
> org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2861)
>         at
> org.apache.camel.support.service.BaseService.init(BaseService.java:83)
>         at
> org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2567)
>         at
> org.apache.camel.support.service.BaseService.start(BaseService.java:111)
>         at
> org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2586)
>         at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247)
>         at org.apache.camel.main.Main.doStart(Main.java:116)
>         at
> org.apache.camel.support.service.BaseService.start(BaseService.java:119)
>         at org.apache.camel.main.MainSupport.run(MainSupport.java:69)
>         at
> org.apache.camel.main.MainCommandLineSupport.run(MainCommandLineSupport.java:174)
>         at org.myorg.camel.MyMainApp.main(MyMainApp.java:21)
> Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
> the registry for: #class:org.myorg.camel.MyProcessor of type:
> org.apache.camel.Processor
>         at
> org.apache.camel.support.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:241)
>         at
> org.apache.camel.reifier.AbstractReifier.mandatoryLookup(AbstractReifier.java:145)
>         at
> org.apache.camel.reifier.ProcessReifier.createProcessor(ProcessReifier.java:40)
>         at
> org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:838)
>         at
> org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579)
>         at
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
>         ... 15 more
>
> Example Code is described:
> https://github.com/chiragsanghavi/camel-experiments/tree/main/processor
>
> Basically referring to processor using <process
> ref="#class:org.myorg.camel.MyProcessor"/> in route directly as described
> in
> https://camel.apache.org/manual/processor.html#_referring_to_beans_using_class_syntax
> .
>
> But it doesn't seem to work.
>
> Are there any other conditions to using #class ?
>
>
> ચિરાગ/चिराग/Chirag
> ------------------------------------------
> Sent from My Gmail Account
>