flowable/flowable-engine · error · ActivitiException
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
Configuration failure in flowable5 JPAEntityMappings.getIdValue: the JPA entity's metadata has neither an id method nor an id field configured, so the primary key of the JPA entity used as a process variable cannot be extracted for serialization. The JPA variable mapping must declare the id method/field.
Source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/variable/JPAEntityMappings.java:109
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 ActivitiException("Illegal argument exception when getting value from id method/field on JPAEntity", iae);
} catch (IllegalAccessException iae) {
throw new ActivitiException("Cannot access id method/field for JPA Entity", iae);
} catch (InvocationTargetException ite) {
throw new ActivitiException("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 ActivitiException("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);
if (metaData == null) {
throw new ActivitiIllegalArgumentException("Class is not a JPA-entity: " + className);
}
// Create primary key of right type
Object primaryKey = createId(metaData, idString);
return findEntity(entityClass, primaryKey);
}
private Object findEntity(Class<?> entityClass, Object primaryKey) {
EntityManager em = ContextView on GitHub (pinned to d6d39ce1c6)
Solutions
- Add a standard @Id (javax.persistence.Id / jakarta.persistence.Id) annotation to a field or getter of the entity
- If using a composite key, ensure the scanner/metadata recognizes the @EmbeddedId setup used by this engine version
- Verify the flowable JPA configuration (jpaHandleTransaction/jpaEntityManagerFactory) points at the right persistence unit
Example fix
// before
@Entity
public class Order { private Long id; }
// after
@Entity
public class Order { @Id private Long id; } Defensive patterns
Strategy: validation
Validate before calling
boolean hasId(Class<?> c) {
for (Field f : c.getDeclaredFields()) if (f.isAnnotationPresent(javax.persistence.Id.class)) return true;
for (Method m : c.getMethods()) if (m.isAnnotationPresent(javax.persistence.Id.class)) return true;
return false;
} Try / catch
try {
runtimeService.setVariable(id, "order", entity);
} catch (ActivitiException e) {
if (e.getMessage().contains("no id method/field set")) {
throw new IllegalStateException("Entity " + entity.getClass() + " lacks @Id", e);
} else { throw e; }
} Prevention
- Always annotate exactly one @Id member per entity
- Avoid relying on @EmbeddedId with this legacy mapping
- Test JPA variable storage for each entity type at startup
When it happens
Trigger: Serializing/deserializing a JPA entity variable whose class has no @Id (or javax.persistence.Id) annotation, or whose id metadata was not detected by the entity scanner.
Common situations: Entities using only @EmbeddedId or a custom key class not recognized; forgot @Id entirely; id annotated with a non-standard annotation; entity scanner configuration missing the class.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Unsupported Primary key type for JPA-Entity: ${type}
- Value of primary key for JPA-Entity cannot be null
- Cannot find field or method with annotation @Id on class '${
- Unsupported Primary key type for JPA-Entity:
- JPA entity variables can only be used in 'variableValueEqual
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/b9496ffe70409a67.
Report an issue: GitHub.