flowable/flowable-engine · error · FlowableException

Cannot get id from JPA Entity, no id method/field set

Error message

Cannot get id from JPA Entity, no id method/field set

What it means

Flowable could not find any way to read the primary key of a JPA entity variable: neither a configured id method nor id field exists in the EntityMetaData for that entity class. After the reflective branches fall through, Flowable throws this FlowableException.

Source

Thrown at modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityMappings.java:106

    }

    public Object getIdValue(Object value, EntityMetaData metaData) {
        try {
            if (metaData.getIdMethod() != null) {
                return metaData.getIdMethod().invoke(value);
            } else if (metaData.getIdField() != null) {
                return metaData.getIdField().get(value);
            }
        } catch (IllegalArgumentException iae) {
            throw new FlowableException("Illegal argument exception when getting value from id method/field on JPAEntity", iae);
        } catch (IllegalAccessException iae) {
            throw new FlowableException("Cannot access id method/field for JPA Entity", iae);
        } catch (InvocationTargetException ite) {
            throw new FlowableException("Exception occurred while getting value from id field/method on JPAEntity: " + ite.getCause().getMessage(), ite.getCause());
        }

        // Fall trough when no method and field is set
        throw new FlowableException("Cannot get id from JPA Entity, no id method/field set");
    }

    public Object getJPAEntity(String className, String idString) {
        Class<?> entityClass = null;
        entityClass = ReflectUtil.loadClass(className);

        EntityMetaData metaData = getEntityMetaData(entityClass);

        // Create primary key of right type
        Object primaryKey = createId(metaData, idString);
        return findEntity(entityClass, primaryKey);
    }

    private Object findEntity(Class<?> entityClass, Object primaryKey) {
        EntityManager em = Context.getCommandContext().getSession(EntityManagerSession.class).getEntityManager();

        Object entity = em.find(entityClass, primaryKey);
        if (entity == null) {

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Add a @Id (javax.persistence/jakarta.persistence) annotation on the entity's id field or getter and rescan/redeploy.
  2. Ensure the entity class (and superclasses holding the id) is registered with Flowable's JPA entity mappings in the process engine configuration.
  3. Verify property vs field access consistency: JPA/Flowable must find the @Id on the access type actually used by the entity.
  4. Rebuild EntityMetaData after changing the entity (Flowable scans classes at startup; stale metadata yields null id method/field).

Example fix

// before
public class Order { private Long id; } // no @Id
// after
@Entity
public class Order {
    @Id
    @GeneratedValue
    private Long id;
}
Defensive patterns

Strategy: validation

Validate before calling

// fail fast at startup if an entity has no discoverable @Id
for (Class<?> c : entityClasses) {
    boolean hasId = java.util.Arrays.stream(c.getDeclaredFields()).anyMatch(f -> f.isAnnotationPresent(javax.persistence.Id.class))
        || java.util.Arrays.stream(c.getMethods()).anyMatch(m -> m.isAnnotationPresent(javax.persistence.Id.class));
    if (!hasId) throw new IllegalStateException(c.getName() + " has no @Id");
}

Try / catch

try {
    Object v = runtimeService.getVariable(executionId, "jpaVar");
} catch (org.flowable.common.engine.api.FlowableException e) {
    if (e.getMessage().contains("no id method/field set")) {
        // fix entity mapping and redeploy
    }
}

Prevention

When it happens

Trigger: getIdValue() is called with metaData.getIdMethod() == null and metaData.getIdField() == null — i.e. the entity class has no @Id-annotated method or field that Flowable's EntityMetaDataScanner could discover, or the entity class was never scanned.

Common situations: Entity missing the @Id annotation entirely; @Id placed on something the scanner does not pick up (e.g. property access mismatch, or id declared only in a superclass that is not scanned/registered); entity class not listed in the JPA entity scan at configuration time; typo in the entity class name in configuration.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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