Federico Mariani created CAMEL-23730:
----------------------------------------

             Summary: ggregateReifier.mandatoryLookup fails during export 
dry-run even with lazyBean=true
                 Key: CAMEL-23730
                 URL: https://issues.apache.org/jira/browse/CAMEL-23730
             Project: Camel
          Issue Type: Bug
          Components: camel-sql
    Affects Versions: 4.20.0
            Reporter: Federico Mariani


When exporting a route that uses an aggregationRepository bean reference (e.g., 
#event_aggregation), the export dry-run fails with NoSuchBeanException even 
though lazyBean=true is set by ExportBaseCommand.runSilently().

The issue is in AggregateReifier.createAggregationRepository() which calls 
mandatoryLookup() to resolve the bean reference. This lookup is not lazy-aware 
and throws immediately if the bean is not in the registry. During the export 
dry-run, beans registered by ContextServicePlugin implementations may not be 
available (e.g., because they require a live database connection or transaction 
manager).

Other reifiers that use mandatoryLookup for bean references (e.g., 
idempotentRepository) may have the same issue.

{code}
org.apache.camel.FailedToCreateRouteException: Failed to create route: 
event-batching
  ...
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the 
registry
  for: #event_aggregation of type: org.apache.camel.spi.AggregationRepository
    at 
org.apache.camel.reifier.AbstractReifier.mandatoryLookup(AbstractReifier.java:178)
    at 
org.apache.camel.reifier.AggregateReifier.createAggregationRepository(AggregateReifier.java:247)
{code}

Expected behavior: When lazyBean=true (as set during camel export), bean 
references in aggregationRepository should be resolved lazily or the lookup 
failure should be treated as non-fatal, allowing the export to complete. The 
exported application resolves the bean correctly at runtime.

Most probably, introduced by: The change from main.setStubPattern("*") to 
main.setStubPattern("component:*") in the exportRun block of Run.java, related 
to CAMEL-23355 / PR #22719 (or the referenced PR #21931).

Root cause: In 4.18, setStubPattern("*") stubbed ALL lookups including bean 
references like #event_aggregation. In 4.20, setStubPattern("component:*") only 
stubs component URIs. Bean references resolved via mandatoryLookup in reifiers 
(e.g., AggregateReifier, IdempotentConsumerReifier) now fail with 
NoSuchBeanException during the export dry-run when the bean is registered by a 
ContextServicePlugin that requires runtime resources (database, transaction 
manager).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to