flowable/flowable-engine · error · FlowableException

error: element is not a CaseElement

Error message

${this.getClass()} error: element is not a CaseElement : ${baseElement.getClass()}

What it means

CaseElementXmlConverter wraps conversion of case-scoped XML elements. After the generic conversion, if the resulting BaseElement is not a CaseElement, the converter cannot attach it to the case and throws FlowableException naming the XML converter class and offending element type.

Solutions

  1. Fix the CMMN XML so the element appears where a CaseElement is valid
  2. Validate the document against the CMMN 1.1 XSD before conversion
  3. If writing a custom converter, ensure it is only registered for XML elements producing CaseElement instances
  4. Inspect the logged class names to identify which element and converter mismatch

Example fix

// before
<planFragment>
  <caseTask .../> <!-- case-scoped element misplaced in a fragment -->
</planFragment>
// after
<case>
  <caseTask .../>
</case>
Defensive patterns

Strategy: validation

Validate before calling

// validate placement of case-scoped elements before conversion
boolean validPlacement = isCaseScopedElementAllowedAt(xmlElementPath);
if (!validPlacement) throw new IllegalArgumentException("Element not allowed at this location in the case model");

Type guard

if (baseElement instanceof CaseElement caseElement) { conversionHelper.addCaseElement(caseElement); } else { throw new IllegalArgumentException("Expected CaseElement, got " + baseElement.getClass()); }

Try / catch

try { converter.convertToCmmnModel(xtr, helper); } catch (FlowableException e) { throw new DeploymentException("Non-CaseElement found by " + e.getMessage(), e); }

Prevention

When it happens

Trigger: A concrete subclass converter expects a case-level element but the parsed element from super.convertToCmmnModel resolves to a non-CaseElement type — e.g. misplaced/nested XML elements or a converter applied to the wrong XML tag.

Common situations: Malformed CMMN XML where a case element is nested inside an incompatible parent; custom/patched converters; schema drift between the XSD and converter expectations.

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/88b2b3eba4ec05aa. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CaseElementXmlConverter.java:34

import org.flowable.cmmn.model.BaseElement;
import org.flowable.cmmn.model.CaseElement;
import org.flowable.cmmn.model.PlanFragment;
import org.flowable.common.engine.api.FlowableException;

/**
 * @author Joram Barrez
 */
public abstract class CaseElementXmlConverter extends BaseCmmnXmlConverter {
    
    @Override
    public abstract String getXMLElementName();
    
    @Override
    public BaseElement convertToCmmnModel(XMLStreamReader xtr, ConversionHelper conversionHelper) {
        BaseElement baseElement = super.convertToCmmnModel(xtr, conversionHelper);
        if (baseElement != null && !(baseElement instanceof CaseElement)) {
            throw new FlowableException(this.getClass() + " error: element is not a CaseElement : " + baseElement.getClass());
        }
        CaseElement caseElement = (CaseElement) baseElement;
        if (caseElement != null) {
            conversionHelper.addCaseElement(caseElement);
            if (!(caseElement instanceof PlanFragment)) {
                caseElement.setParent(conversionHelper.getCurrentPlanFragment());
            } 
        }
        return caseElement;
    }
    
}

View on GitHub (pinned to d6d39ce1c6)