[
https://issues.apache.org/jira/browse/CAMEL-25833?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-25833.
---------------------------------
Resolution: Fixed
> camel-jbang - camel run --dev: a dependency added to camel.jbang.dependencies
> while the app runs is not downloaded
> ------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25833
> URL: https://issues.apache.org/jira/browse/CAMEL-25833
> Project: Camel
> Issue Type: Improvement
> Components: camel-jbang
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> {{camel run}} reads {{camel.jbang.dependencies}} from application.properties
> before the app starts, and hands the list to KameletMain. KameletMain
> downloads it once, when the app starts
> ({{CommandLineDependencyDownloader.doInit}}). In dev mode, a dependency that
> is added while the app runs is not downloaded. Only a restart picks it up.
> With CAMEL-25767 (PR #28123), a reload creates the beans that are new in
> {{camel.beans.*}}. A bean whose class comes from such a dependency then
> fails. Reproduced with {{camel run --source-dir=. --dev}} and the camel
> launcher built from that PR, by appending to application.properties while the
> app runs:
> {noformat}
> camel.jbang.dependencies = com.github.javafaker:javafaker:1.0.2
> camel.beans.faker = #class:com.github.javafaker.Faker
> {noformat}
> {noformat}
> INFO RouteWatcherReloadStrategy : Reloading properties:
> file:application.properties. (Only Camel routes and components can be updated
> with changes)
> WARN FileWatcherResourceReloadStrategy : Error reloading routes from file:
> application.properties due to: com.github.javafaker.Faker. This exception is
> ignored.
> java.lang.ClassNotFoundException: com.github.javafaker.Faker
> at
> org.apache.camel.impl.engine.DefaultClassResolver.resolveMandatoryClass(DefaultClassResolver.java:136)
> at
> org.apache.camel.main.BaseMainSupport.createBeanViaInferredBuilder(BaseMainSupport.java:2772)
> at
> org.apache.camel.main.BaseMainSupport.bindBeansToRegistry(BaseMainSupport.java:2867)
> at
> org.apache.camel.main.BaseMainSupport.bindReloadedBeans(BaseMainSupport.java:2831)
> ...
> {noformat}
> With the same two lines in application.properties before the app starts,
> javafaker is downloaded and the bean is bound. Classes that camel-jbang knows
> (such as {{org.apache.activemq.artemis}}, in
> known-third-party-libraries.properties) are downloaded when they are used, so
> they work in a reload too. Other libraries do not.
> This is how a coding agent adds a library. The AI tools of the
> camel-jbang-mcp server tell it to declare
> {{camel.jbang.dependencies=<groupId>:<artifactId>:<version>}} in
> application.properties ({{DependencyLookup}}, {{BeanRefChecks}},
> {{GroovyImportChecks}}). The agent does that while the app runs in dev mode.
> The tools do not say that a restart is needed.
> Proposal: when a reloaded properties file changes
> {{camel.jbang.dependencies}}, download the new dependencies before the beans
> and components of that reload are created, as
> {{CommandLineDependencyDownloader}} does at startup
> ({{DependencyDownloader.downloadDependency}}). A dependency that is removed
> stays on the classpath until a restart, which can be logged.
> Related, found in the same test: when application.properties is saved
> together with another file (here a route, found in the same scan of the
> folder), the error is not logged at all.
> {{RouteWatcherReloadStrategy.onReloadBatch}} (CAMEL-25041, 4.23.0) catches
> the failure of the batch, logs it at DEBUG, and reloads the files one at a
> time. By then the properties component has the new values, so the properties
> file has no changes left, and nothing fails. The routes reload, the bean is
> missing, and the log does not say why. This is not only about dependencies:
> the failure of any properties reload in a batch is lost.
> Found while testing CAMEL-25767.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)