Activiti/Activiti · error · UnsupportedOperationException

Environment variables are read-only

Error message

Environment variables are read-only

What it means

EnvironmentVariableELResolver is a read-only EL resolver that maps identifiers to OS environment variables during expression evaluation. Its setValue() unconditionally throws UnsupportedOperationException because mutating environment variables through EL is not allowed. Any expression that attempts to assign to a resolved environment variable triggers this.

Solutions

  1. Remove the assignment from the expression; read environment variables only, and store mutable data in process/executions variables.
  2. Use execution.setVariable() or runtimeService.setVariable() instead of EL assignment.
  3. Rename the target variable if it unintentionally collides with an environment variable name.

Example fix

// before (process expression)
${PATH = '/new/path'}
// after (Java)
execution.setVariable("targetVar", "/new/path");
Defensive patterns

Strategy: try-catch

Try / catch

try {
    elResolver.setValue(elContext, base, property, value);
} catch (UnsupportedOperationException e) {
    log.warn("EL attempted to write an environment variable; use process variables instead", e);
}

Prevention

When it happens

Trigger: Evaluating a process expression that performs an assignment targeting an identifier that resolves to an environment variable (e.g. ${someEnvVar = 'x'} in a script/expression evaluated by the Activiti EL context).

Common situations: Accidentally writing to a variable whose name collides with an environment variable name, misunderstanding the resolver as writable, or copy-pasting assignment expressions from other contexts.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09). Data as JSON: /api/errors/1d91394edcdb709c. Report an issue: GitHub.

Appendix: source

Thrown at activiti-core/activiti-spring-boot-starter/src/main/java/org/activiti/spring/resolver/EnvironmentVariableELResolver.java:47

            context.setPropertyResolved(true);
            return new EnvVar();
        }
        if (base instanceof EnvVar && property != null) {
            String env = System.getenv(VAR_PREFIX_WITH_DOT + property);
            context.setPropertyResolved(true);
            return env;
        }
        return null;
    }

    @Override
    public Class<?> getType(ELContext elContext, Object o, Object o1) {
        return String.class;
    }

    @Override
    public void setValue(ELContext elContext, Object o, Object o1, Object o2) {
        throw new UnsupportedOperationException("Environment variables are read-only");
    }

    @Override
    public boolean isReadOnly(ELContext elContext, Object o, Object o1) {
        return true;
    }

    @Override
    public Class<?> getCommonPropertyType(ELContext elContext, Object o) {
        return String.class;
    }
}

View on GitHub (pinned to 56435b1a97)