davsclaus opened a new pull request, #26455: URL: https://github.com/apache/camel/pull/26455
Fixes https://issues.apache.org/jira/browse/CAMEL-24709 The class-not-found hint for YAML `beans:` (CAMEL-24702) only knew the aggregation strategies in `org.apache.camel.processor.aggregate`. It now reads the bean metadata the build tools generate into every JAR that has built-in beans (`META-INF/services/org/apache/camel/bean.properties` + `bean/<Name>.json`), so any of the 65 built-in beans (aggregation strategies, idempotent/aggregation repositories, header filter strategies, ...) written with the wrong package or no package gets a data-driven answer: ``` Error creating bean: myAgg of type: #class:com.foo.UseLatestAggregationStrategy: class com.foo.UseLatestAggregationStrategy was not found (did you mean org.apache.camel.processor.aggregate.UseLatestAggregationStrategy (org.apache.camel.AggregationStrategy)? write: type: org.apache.camel.processor.aggregate.UseLatestAggregationStrategy) ``` The same metadata backs the reifiers, so a `#class:` aggregation strategy, repository or other typed lookup whose class does not exist now says what was likely meant, or lists the built-in beans of the expected interface, instead of the bare `Cannot find AggregationStrategy in Registry with name: ...`: ``` No bean could be found in the registry for: #class:com.foo.MyStrategy of type: org.apache.camel.AggregationStrategy (check the package name; a class from another library needs its dependency added; the built-in AggregationStrategy beans are GroupedBodyAggregationStrategy (org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy), ... and 1 more) ``` ### Changes - **camel-support** — new `PojoBeanHelper`: scans `bean.properties` / `bean/*.json` through the context's class resolver on the error path only (`findAll`, `findByName`, `beansOfInterface`, `classNotFoundHint`, `missingClassName`) - **camel-api** — `NoSuchBeanException(name, type, hint)` constructor (`@since 4.23`) - **camel-core-reifier** — `AbstractReifier.lookupByName(name, expectedType)` and `mandatoryLookup` append the hint; the four aggregation-strategy lookups (Processor/Split/Multicast/RecipientList reifiers) use the typed variant - **camel-support** — `EndpointHelper.resolveReferenceParameter` appends the hint on the `#class:`-not-found path (the class miss is a `null` return from `createBean`, not an exception) - **camel-yaml-dsl** — `BeansDeserializer.classNotFoundHint` is data driven; the hardcoded package is gone ### Not done (metadata limitation) Naming the missing artifact (`add camel-zipfile`) is not possible at runtime: the metadata lives in the same JAR as the bean, so it is absent exactly when the JAR is. That needs a build-generated table (like `SensitiveUtils`); tracked separately. ### Tests `PojoBeanHelperTest` (7), `AggregationStrategyClassNotFoundHintTest` (4), 3 new cases in `BeansTest.groovy`, 2 in `AggregateTest.groovy`. Ran camel-support (125), the affected camel-core packages (960) and the full camel-yaml-dsl suite (427) — all green. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
