flowable/flowable-engine · error · FlowableException

Could not find CamelContext named ${camelContextValue}.

Error message

Could not find CamelContext named ${camelContextValue}.

What it means

SpringCamelBehavior.resolveCamelContext looks up the named Spring bean via the application context from a SpringProcessEngineConfiguration and requires it to be a SpringCamelContext. Flowable throws this FlowableException when the bean with the configured camelContext name exists but is not a SpringCamelContext instance.

Source

Thrown at modules/flowable-camel/src/main/java/org/flowable/camel/SpringCamelBehavior.java:80

    protected CamelContext resolveCamelContext(String camelContextValue, boolean isV5Execution) {
        ProcessEngineConfiguration engineConfiguration = org.flowable.engine.impl.context.Context.getProcessEngineConfiguration();
        if (isV5Execution) {

            Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();
            return (CamelContext) compatibilityHandler.getCamelContextObject(camelContextValue);

        } else {
            // Convert it to a SpringProcessEngineConfiguration. If this doesn't work, throw a RuntimeException.
            try {
                SpringProcessEngineConfiguration springConfiguration = (SpringProcessEngineConfiguration) engineConfiguration;
                if (StringUtils.isEmpty(camelContextValue)) {
                    camelContextValue = springConfiguration.getDefaultCamelContext();
                }

                // Get the CamelContext object and set the super's member variable.
                Object ctx = springConfiguration.getApplicationContext().getBean(camelContextValue);
                if (!(ctx instanceof SpringCamelContext)) {
                    throw new FlowableException("Could not find CamelContext named " + camelContextValue + ".");
                }
                return (SpringCamelContext) ctx;

            } catch (Exception e) {
                throw new FlowableException("Expecting a SpringProcessEngineConfiguration for the Camel module.", e);
            }
        }
    }

    
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Make sure the referenced bean is a org.apache.camel.spring.SpringCamelContext declared in the Spring application context.
  2. Check the camelContext attribute/field value on the flowable service task or SpringCamelBehavior configuration points at the correct bean name.
  3. Do not use a manually constructed DefaultCamelContext; create the context via spring <camelContext> or CamelSpringBootApplication so the bean type is SpringCamelContext.
  4. Verify springConfiguration is a SpringProcessEngineConfiguration and the applicationContext contains the bean.

Example fix

// before
<bean id="camelContext" class="org.apache.camel.impl.DefaultCamelContext"/>
// after
<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring"/> <!-- SpringCamelContext -->
Defensive patterns

Strategy: validation

Validate before calling

Object bean = springConfiguration.getApplicationContext().getBean(camelContextName);
if (!(bean instanceof SpringCamelContext)) {
    throw new IllegalStateException("Bean '" + camelContextName + "' must be a SpringCamelContext");
}

Type guard

if (obj instanceof org.apache.camel.spring.SpringCamelContext sc) { /* safe to use */ }

Try / catch

try {
    return springCamelBehavior.getCamelContext();
} catch (FlowableException e) {
    if (e.getMessage().startsWith("Could not find CamelContext named")) {
        // log bean name + actual bean type for diagnosis
    }
    throw e;
}

Prevention

When it happens

Trigger: The 'camelContext' field on the camel behavior/service task points at a bean whose type is not SpringCamelContext (e.g. a plain DefaultCamelContext, or the bean lookup returned a different type), or getBean returned null/non-Camel bean with the given name.

Common situations: Referencing a DefaultCamelContext bean instead of SpringCamelContext in a Spring application; typos mapping to another bean of unrelated type; using camel-spring vs plain camel inconsistently; specifying a camelContext name that resolves to null inside getBean when the name key was picked from the wrong source.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/42798d28df9e12b9. Report an issue: GitHub.