flowable/flowable-engine · error · FlowableException

Unexpected exception getting variable data

Error message

Unexpected exception getting variable data

What it means

While serializing a historic variable's value to bytes for the /data endpoint, an IOException can occur (e.g. the value is not java.io.Serializable or serialization fails). The resource wraps it in a FlowableException with the generic message "Unexpected exception getting variable data" and the IOException as cause.

Source

Thrown at modules/flowable-rest/src/main/java/org/flowable/rest/service/api/history/HistoricProcessInstanceVariableDataResource.java:87

                result = (byte[]) variable.getValue();
                response.setContentType("application/octet-stream");

            } else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
                ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
                outputStream.writeObject(variable.getValue());
                outputStream.close();
                result = buffer.toByteArray();
                response.setContentType("application/x-java-serialized-object");

            } else {
                throw new FlowableObjectNotFoundException("The variable does not have a binary data stream.", null);
            }
            return result;

        } catch (IOException ioe) {
            // Re-throw IOException
            throw new FlowableException("Unexpected exception getting variable data", ioe);
        }
    }

    public RestVariable getVariableFromRequest(boolean includeBinary, String processInstanceId, String variableName) {

        HistoricProcessInstance processObject = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult();

        if (processObject == null) {
            throw new FlowableObjectNotFoundException("Historic process instance '" + processInstanceId + "' could not be found.", HistoricProcessInstanceEntity.class);
        }
        
        if (restApiInterceptor != null) {
            restApiInterceptor.accessHistoryProcessInfoById(processObject);
        }

        Object value = processObject.getProcessVariables().get(variableName);

        if (value == null) {

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Inspect the wrapped IOException cause in server logs for the real serialization error
  2. Ensure values stored as serializable variables implement java.io.Serializable with a stable serialVersionUID
  3. Store simple JSON strings or byte arrays instead of raw Java objects to avoid deserialization coupling
  4. Check that the REST server's classpath contains the variable payload classes at the same version used when the variable was written

Example fix

// before
class ReportData { String title; }                       // not Serializable
// after
class ReportData implements java.io.Serializable {
    private static final long serialVersionUID = 1L;
    String title;
}
Defensive patterns

Strategy: try-catch

Validate before calling

const v = await get(`/history/process-instances/${pid}/variables/${name}`); if (v.type === 'serializable' && !v.valueUrl) throw new Error('serializable payload may be unreadable');

Type guard

const isSerializableType = (v) => v?.type === 'serializable';

Try / catch

catch (e) { if (e.response && e.response.status >= 500 && /Unexpected exception getting variable data/.test(e.response.data.message || '')) { /* inspect server logs for the IOException cause */ } throw e; }

Prevention

When it happens

Trigger: GET /history/process-instances/{id}/variables/{name}/data where the serializable variable's stored object cannot be serialized back to bytes (non-serializable class, classpath/serialization-version mismatch, corrupted stored value).

Common situations: Variable payload classes changed between deployments so serialVersionUID no longer matches; storing objects of classes missing implements Serializable; engine/database upgrades leaving incompatible serialized blobs.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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