You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "fvcortes (via GitHub)" <gi...@apache.org> on 2024/04/28 15:54:47 UTC

[I] Cannot find RoutesBuilderLoader in classpath for native application [camel-quarkus]

fvcortes opened a new issue, #6049:
URL: https://github.com/apache/camel-quarkus/issues/6049

   ### Bug description
   
   ## Issue
   When attempting to load routes from YAML content using a fresh CamelContext in native execution, the application cannot locate an appropriate RoutesBuilderLoader in the classpath that supports the file extension `.yaml` (camel-quarkus-yaml-dsl dependency included).
   
   ## Expected Behavior
   The expected behavior is to successfully load routes using the fresh CamelContext without errors.
   
   ## Actual Behavior
   Instead, the method call throws an exception when trying to load routes for the given YAML content.
   
   ## How to Reproduce
   A minimal reproducer is set up at:
   [GitHub - fvcortes/camel-context-main](https://github.com/fvcortes/camel-context-main/tree/master)
   
   ### JVM Executable
   #### Build:
   ```sh
   mvn clean package
   ```
   #### Run:
   ```sh
   java -jar target/quarkus-app/quarkus-run.jar LSBmcm9tOgogICAgdXJpOiAiZGlyZWN0Om15LXJvdXRlIgogICAgc3RlcHM6CiAgICAgIC0gbG9nOgogICAgICAgICAgbWVzc2FnZTogIkxvZ2dpbmcgZnJvbSBteS1yb3V0ZS4uLiI=
   ```
   #### Output:
   ```
   2024-04-28 10:55:20,416 INFO  [io.quarkus] (main) camel-quarkus-context-main 1.0.0 on JVM (powered by Quarkus 3.9.1) started in 0.540s. 
   2024-04-28 10:55:20,419 INFO  [io.quarkus] (main) Profile prod activated. 
   2024-04-28 10:55:20,419 INFO  [io.quarkus] (main) Installed features: [camel-core, camel-yaml-dsl, cdi]
   2024-04-28 10:55:20,496 INFO  [org.acm.mai.Main] (main) Routes loaded successfully.
   2024-04-28 10:55:20,498 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-2) is shutting down (timeout:45s)
   2024-04-28 10:55:20,502 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes stopped (stopped:0)
   2024-04-28 10:55:20,511 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-2) shutdown in 14ms (uptime:)
   ```
   
   ### Native Executable
   #### Build:
   ```sh
   mvn clean package -Pnative
   ```
   #### Run:
   ```sh
   ./target/*-runner LSBmcm9tOgogICAgdXJpOiAiZGlyZWN0Om15LXJvdXRlIgogICAgc3RlcHM6CiAgICAgIC0gbG9nOgogICAgICAgICAgbWVzc2FnZTogIkxvZ2dpbmcgZnJvbSBteS1yb3V0ZS4uLiI=
   ```
   #### Output:
   ```log
   2024-04-28 10:58:46,556 INFO  [io.quarkus] (main) camel-quarkus-context-main 1.0.0 native (powered by Quarkus 3.9.1) started in 0.006s. 
   2024-04-28 10:58:46,556 INFO  [io.quarkus] (main) Profile prod activated. 
   2024-04-28 10:58:46,556 INFO  [io.quarkus] (main) Installed features: [camel-core, camel-yaml-dsl, cdi]
   2024-04-28 10:58:46,559 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-2) is shutting down (timeout:45s)
   2024-04-28 10:58:46,559 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes stopped (stopped:0)
   2024-04-28 10:58:46,560 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-2) shutdown in 0ms (uptime:)
   2024-04-28 10:58:46,560 ERROR [io.qua.run.Application] (main) Failed to start application (with profile [prod]): java.lang.IllegalArgumentException: Cannot find RoutesBuilderLoader in classpath supporting file extension: yaml
           at org.apache.camel.impl.engine.DefaultRoutesLoader.resolveRoutesBuilderLoader(DefaultRoutesLoader.java:298)
           at org.apache.camel.impl.engine.DefaultRoutesLoader.findRoutesBuilders(DefaultRoutesLoader.java:124)
           at org.apache.camel.impl.engine.DefaultRoutesLoader.findRoutesBuilders(DefaultRoutesLoader.java:101)
           at org.apache.camel.spi.RoutesLoader.findRoutesBuilders(RoutesLoader.java:133)
           at org.apache.camel.spi.RoutesLoader.loadRoutes(RoutesLoader.java:85)
           at org.acme.main.Main.load(Main.java:58)
           at org.acme.main.Main.run(Main.java:50)
           at org.acme.main.Main_ClientProxy.run(Unknown Source)
           at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:132)
           at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
           at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
           at org.acme.main.Main.main(Main.java:38)
   
   2024-04-28 10:58:46,560 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-1) is shutting down (timeout:45s)
   2024-04-28 10:58:46,560 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes stopped (stopped:0)
   2024-04-28 10:58:46,560 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-1) shutdown in 0ms (uptime:)
   2024-04-28 10:58:46,561 INFO  [io.quarkus] (main) camel-quarkus-context-main stopped in 0.000s
   ```
   
   ## Alternative Solution
   For this specific task of dynamically loading routes, I've set up a branch in the reproducer that utilizes the CamelRuntime retrieved from Quarkus ARC. This provides a CamelContext that successfully loads routes in native mode:
   
   [GitHub Branch - arc-camel-context-main](https://github.com/fvcortes/camel-context-main/tree/arc-camel-context-main)
   
   This issue may not necessarily be a bug, but rather unexpected behavior from which I was expecting more clarity. I might be missing something about Camel context initialization in a Camel-Quarkus environment and would appreciate enlightenment on this topic. 
   
   Thank you in advance for your help.


-- 
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-unsubscribe@camel.apache.org.apache.org

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


Re: [I] Cannot find RoutesBuilderLoader in classpath for native application [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on issue #6049:
URL: https://github.com/apache/camel-quarkus/issues/6049#issuecomment-2081599076

   Without additional configuration `new DefaultCamelContext()` is pretty much guranteed to fail in native mode.
   
   There shouldn't really be any need to instantiate own `CamelContext`. One is already created for you at build time and you can customize it with configuration properties, CDI beans, observers etc.
   
   You can also `@Inject` an instance of it into your `Main` class.


-- 
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-unsubscribe@camel.apache.org

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


Re: [I] Cannot find RoutesBuilderLoader in classpath for native application [camel-quarkus]

Posted by "fvcortes (via GitHub)" <gi...@apache.org>.
fvcortes commented on issue #6049:
URL: https://github.com/apache/camel-quarkus/issues/6049#issuecomment-2081610028

   Thanks for your answer @jamesnetherton and I appreciate your tip on using the injectable bean CamelContext.
   I understand that instantiating a camel context manually with no configuration is not adequate for native execution, hence this is not a legitimate bug request.
   In this particular scenario, I would also like to make use of the initialization capabilities of the `init()` method, provided by the AbstractCamelContext implementation but the CamelContext injectable bean doesn't seem to provide one since the everything is already set up at this point.
   Do you have any suggestions?
   
   


-- 
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-unsubscribe@camel.apache.org

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


Re: [I] Cannot find RoutesBuilderLoader in classpath for native application [camel-quarkus]

Posted by "fvcortes (via GitHub)" <gi...@apache.org>.
fvcortes closed issue #6049: Cannot find RoutesBuilderLoader in classpath for native application
URL: https://github.com/apache/camel-quarkus/issues/6049


-- 
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-unsubscribe@camel.apache.org

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


Re: [I] Cannot find RoutesBuilderLoader in classpath for native application [camel-quarkus]

Posted by "fvcortes (via GitHub)" <gi...@apache.org>.
fvcortes closed issue #6049: Cannot find RoutesBuilderLoader in classpath for native application
URL: https://github.com/apache/camel-quarkus/issues/6049


-- 
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-unsubscribe@camel.apache.org

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