You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/06/16 08:10:35 UTC

[GitHub] [camel-k-runtime] astefanutti opened a new issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

astefanutti opened a new issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362


   In this example https://github.com/astefanutti/camel-k-example-metrics, I've declared a CDI bean in an external beans archive, that I use in a Camel K route.
   
   However, this leads to the following exception when the integration starts:
   
   ```
   2020-06-15 16:00:35,124 ERROR [io.qua.application] (main) Failed to start application: java.lang.RuntimeException: org.apache.camel.FailedToCreateRouteException: Failed to create route unreliable-service at: >>> process[Processor@0x0] <<< in route: Route(unreliable-service)[From[timer:stream?period=1000] -> ... because of ref must be specified on: process[Processor@0x0]
   	at org.apache.camel.quarkus.core.CamelMainRecorder.start(CamelMainRecorder.java:99)
   	at io.quarkus.deployment.steps.Main$start317617795.deploy_0(Main$start317617795.zig:115)
   	at io.quarkus.deployment.steps.Main$start317617795.deploy(Main$start317617795.zig:36)
   	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:522)
   	at io.quarkus.runtime.Application.start(Application.java:90)
   	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:90)
   	at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
   	at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
   	at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
   	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
   Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route unreliable-service at: >>> process[Processor@0x0] <<< in route: Route(unreliable-service)[From[timer:stream?period=1000] -> ... because of ref must be specified on: process[Processor@0x0]
   	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:393)
   	at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:117)
   	at org.apache.camel.quarkus.core.FastCamelContext.startRouteDefinitions(FastCamelContext.java:694)
   	at org.apache.camel.quarkus.core.FastCamelContext.startRouteDefinitions(FastCamelContext.java:486)
   	at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2617)
   	at org.apache.camel.quarkus.core.FastCamelContext.doInit(FastCamelContext.java:372)
   	at org.apache.camel.support.service.BaseService.init(BaseService.java:83)
   	at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2450)
   	at org.apache.camel.quarkus.core.CamelMain.doInit(CamelMain.java:47)
   	at org.apache.camel.support.service.BaseService.init(BaseService.java:83)
   	at org.apache.camel.support.service.BaseService.start(BaseService.java:111)
   	at org.apache.camel.quarkus.core.CamelMainRecorder.start(CamelMainRecorder.java:97)
   	... 9 more
   Caused by: java.lang.IllegalArgumentException: ref must be specified on: process[Processor@0x0]
   	at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:171)
   	at org.apache.camel.reifier.ProcessReifier.createProcessor(ProcessReifier.java:39)
   	at org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:766)
   	at org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:511)
   	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:391)
   	... 20 more
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] astefanutti closed issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
astefanutti closed issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] astefanutti commented on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
astefanutti commented on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-647522128


   @lburgazzoli awesome. I'll try it ASAP. Let me close this then.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] lburgazzoli commented on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-646007554


   yeah that is because under the hood it does 
   
       camelContext.getClassResolver().resolveMandatoryClass(beanType)
   
   so it won't search for a service but it will instantiate one
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] lburgazzoli commented on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-647412898


   @astefanutti the injection issue has been fixed in camel-quakrus and will be available in the next release


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] astefanutti commented on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
astefanutti commented on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-646049178


   @davsclaus here we go: https://issues.apache.org/jira/browse/CAMEL-15217.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] lburgazzoli edited a comment on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
lburgazzoli edited a comment on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-646007554


   yeah that is because under the hood the BeanReifier does 
   
       camelContext.getClassResolver().resolveMandatoryClass(beanType)
   
   so it won't search for a bean of type Servic but it will instantiate a new instance
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] lburgazzoli edited a comment on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
lburgazzoli edited a comment on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-645578984


   The reason of the failure is because of a wrong ordering of loading routes and post process them in camel-quarkus so the call to `configure()` method happens before the post processor kicks in, thus the `service` bean is not yet injected when bound to the route.
   
   However, if you change the processor invocation from `.process(service)` to `process("service")` then the route should not fail to start and your processor will be invoked.
   
   Opened an [issue](https://github.com/apache/camel-quarkus/issues/1368) on camel-quarkus 
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] lburgazzoli commented on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-645578984


   The reason of the failure is because of a wrong life-cycle of routes in camel-quarkus so the call to `configure()` method happens before the post processor kicks in, thus beans are not yet injected.
   
   However, if you change the processor invocation from `.process(service)` to `process("service")` then the route should not fail to start and your processor will be invoked.
   
   Opened an [issue](https://github.com/apache/camel-quarkus/issues/1368) on camel-quarkus 
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] astefanutti commented on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
astefanutti commented on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-645995989


   It seems however lookup by type does not work:
   
   https://github.com/astefanutti/camel-k-example-metrics/commit/9837214baf28ded239171c48e5f91b8f1a616509
   
   There is no error, but the bean instances are not the same so the method handler interceptor does not work.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] astefanutti commented on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
astefanutti commented on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-645919930


   Thanks a lot! I confirm `process("service")` works.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] astefanutti commented on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
astefanutti commented on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-646008866


   That is what I suspected, but I find it a bit confusing that `bean("beanName")` does lookup into the registry, while `bean(Bean.class)` does not.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] davsclaus commented on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-646023927


   @astefanutti yeah we can make bean(class) lookup too and if there is a single bean of that type then use it. However Camel did not have lookup anonymous by type in the beginning, and hence why bean is like that.
   
   Would you create a JIRA ticket at Camel 3 project for this improvement


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] lburgazzoli edited a comment on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
lburgazzoli edited a comment on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-646007554


   yeah that is because under the hood the BeanReifier does 
   
       camelContext.getClassResolver().resolveMandatoryClass(beanType)
   
   so it won't search for a bean of type `Service` but it will instantiate a new instance
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k-runtime] lburgazzoli edited a comment on issue #362: Injecting a CDI bean managed by Quarkus into Camel K routes leads to a null reference

Posted by GitBox <gi...@apache.org>.
lburgazzoli edited a comment on issue #362:
URL: https://github.com/apache/camel-k-runtime/issues/362#issuecomment-645578984


   The reason of the failure is because of a wrong ordering of loading routes and post process them in camel-quarkus so the call to `configure()` method happens before the post processor kicks in, thus the `service` bean is not yet injected when bound to the route.
   
   However, if you change the processor invocation from `.process(service)` to `process("service")` (so by name) then the route should not fail to start and your processor will be invoked.
   
   Opened an [issue](https://github.com/apache/camel-quarkus/issues/1368) on camel-quarkus 
   
   


----------------------------------------------------------------
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:
users@infra.apache.org