Federico Mariani created CAMEL-28093:
----------------------------------------

             Summary: camel-jbang - camel export fails for a route with 
transacted and a policy ref: No bean could be found for PROPAGATION_REQUIRED
                 Key: CAMEL-28093
                 URL: https://issues.apache.org/jira/browse/CAMEL-28093
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang
    Affects Versions: 4.24.0
            Reporter: Federico Mariani


camel export of a route whose transacted step refers to a policy by name fails 
on 4.24.0. The export loads the routes to find their dependencies, and a policy 
that the application registers at runtime, such as a SpringTransactionPolicy 
bean named PROPAGATION_REQUIRED on Spring Boot, is not in the registry then. 
4.22.3 exports the same route.

Reproducer, without plugins:
{code:yaml}
- route:
    id: tx
    from:
      uri: timer:tick
      parameters:
        repeatCount: 1
      steps:
        - transacted:
            ref: PROPAGATION_REQUIRED
        - log:
            message: in transaction
{code}
{code}
camel export tx.camel.yaml --runtime=spring-boot --gav=org.example:tx:1.0 
--directory=out
{code}
4.24.0 exits with 70 and writes no project; --runtime=camel-main fails the same 
way:
{code}
ERROR: Failed to create route: tx at: >>> Transacted[ref:PROPAGATION_REQUIRED] 
<<< in route: ...
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the 
registry for: PROPAGATION_REQUIRED of type: org.apache.camel.spi.Policy
{code}
4.22.3 exports it to both runtimes.

Cause: in 4.22.3, TransactedDownloader bound a dummy policy under all seven 
PROPAGATION_* names for any transacted step. Since CAMEL-26850, 
bindPassThroughPolicies skips a transacted step with a ref, so 
AbstractPolicyReifier.resolvePolicy fails at mandatoryLookup(ref, Policy.class) 
while exporting.

Workaround: camel export --ignore-loading-error. It also hides other loading 
errors, and the application still needs its PROPAGATION_REQUIRED bean at 
runtime.

Suggested fix: while exporting only, bind the pass-through policy under a ref 
that is one of the seven PROPAGATION_* names and has no bean, for the 
CamelContext of the route (the reifier is registered for the JVM). camel run 
still fails on the missing bean.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to