flowable/flowable-engine · error · FlowableException

Error parsing event definition JSON

Error message

Error parsing event definition JSON

What it means

EventDefinitionParse.execute() reads the event definition JSON, converts it into an EventModel via the event model JSON converter, and builds EventDefinitionEntity instances. Any exception in this pipeline — stream read failures, invalid JSON, schema mismatches — is wrapped in a FlowableException with this message, preserving the underlying cause.

Source

Thrown at modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/parser/EventDefinitionParse.java:84

    public EventDefinitionParse execute(EventRegistryEngineConfiguration eventEngineConfig) {
        String encoding = eventEngineConfig.getXmlEncoding();
        EventJsonConverter converter = eventEngineConfig.getEventJsonConverter();

        try (InputStreamReader in = newInputStreamReaderForSource(encoding)) {
            String eventJson = IOUtils.toString(in);
            eventModel = converter.convertToEventModel(eventJson);

            if (eventModel != null && eventModel.getKey() != null) {
                EventDefinitionEntity eventDefinitionEntity = eventEngineConfig.getEventDefinitionEntityManager().create();
                eventDefinitionEntity.setKey(eventModel.getKey());
                eventDefinitionEntity.setName(eventModel.getName());
                eventDefinitionEntity.setResourceName(name);
                eventDefinitionEntity.setDeploymentId(deployment.getId());
                eventDefinitions.add(eventDefinitionEntity);
            }
        } catch (Exception e) {
            throw new FlowableException("Error parsing event definition JSON", e);
        }
        return this;
    }

    private InputStreamReader newInputStreamReaderForSource(String encoding) throws UnsupportedEncodingException {
        if (encoding != null) {
            return new InputStreamReader(streamSource.getInputStream(), encoding);
        } else {
            return new InputStreamReader(streamSource.getInputStream());
        }
    }

    public EventDefinitionParse name(String name) {
        this.name = name;
        return this;
    }

    public EventDefinitionParse sourceInputStream(InputStream inputStream) {

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Validate the event JSON structure (must include 'key' and a valid 'payload' section) against the Flowable event definition schema
  2. Check getCause() on the exception to distinguish IO/encoding failures from JSON parse failures
  3. Verify the file is an event definition (not a channel definition) and is non-empty/not truncated
  4. Lint the JSON with a standard parser to catch syntax errors before deployment

Example fix

// before: events/orderCreated.event
{"key": "orderCreated" "payload": {"customerId": "string"}}  // missing comma -> parse fails
// after
{"key": "orderCreated", "payload": {"customerId": "string"}}
Defensive patterns

Strategy: validation

Validate before calling

JsonObject obj = Json.parseReader(new FileReader(eventFile)).getAsJsonObject();
if (!obj.has("key") || obj.get("key").getAsString().isEmpty()) {
    throw new IllegalArgumentException("Event JSON missing 'key': " + eventFile);
}

Try / catch

try {
    parse.execute();
} catch (FlowableException e) {
    if (e.getMessage().equals("Error parsing event definition JSON")) {
        log.error("Event JSON invalid", e.getCause());
    }
}

Prevention

When it happens

Trigger: Deploying an event definition resource whose content is not valid event-definition JSON, whose required fields (key, payload) are missing, or whose stream cannot be read/decoded.

Common situations: .event files with JSON syntax errors; deploying a channel JSON file with an .event extension; empty or truncated files from a failed build copy; Flowable version upgrades changing the expected event JSON schema.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


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