flowable/flowable-engine · error · ActivitiException
Entity does not exist: -
Error message
Entity does not exist: -
What it means
findEntity performs EntityManager.find(entityClass, primaryKey); if the persistence layer returns null, the engine throws this ActivitiException because the stored variable references an entity row that no longer exists.
Source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/variable/JPAEntityMappings.java:134
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 = Context
.getCommandContext()
.getSession(EntityManagerSession.class)
.getEntityManager();
Object entity = em.find(entityClass, primaryKey);
if (entity == null) {
throw new ActivitiException("Entity does not exist: " + entityClass.getName() + " - " + primaryKey);
}
return entity;
}
public Object createId(EntityMetaData metaData, String string) {
Class<?> type = metaData.getIdType();
// According to JPA-spec all primitive types (and wrappers) are supported, String, util.Date, sql.Date,
// BigDecimal and BigInteger
if (type == Long.class || type == long.class) {
return Long.parseLong(string);
} else if (type == String.class) {
return string;
} else if (type == Byte.class || type == byte.class) {
return Byte.parseByte(string);
} else if (type == Short.class || type == short.class) {
return Short.parseShort(string);
} else if (type == Integer.class || type == int.class) {
return Integer.parseInt(string);View on GitHub (pinned to d6d39ce1c6)
Solutions
- Recreate the missing row or complete/terminate the process instance referencing it
- Verify the engine's EntityManagerFactory/datasource configuration matches the database holding the entity
- Prevent deletion of entities still referenced by running process instances (FK/soft-delete)
- Handle ActivitiException when reading variables that may reference deleted entities
Example fix
// before
Order order = (Order) runtimeService.getVariable(executionId, "order"); // throws if row deleted
// after
Order row = em.find(Order.class, storedId);
if (row != null) {
Order order = (Order) runtimeService.getVariable(executionId, "order");
} else {
runtimeService.removeVariable(executionId, "order");
} Defensive patterns
Strategy: try-catch
Validate before calling
Object exists = em.find(Order.class, storedId);
if (exists == null) {
runtimeService.removeVariable(executionId, "order");
} Try / catch
try {
Order order = (Order) runtimeService.getVariable(executionId, "order");
} catch (ActivitiException e) {
if (e.getMessage().startsWith("Entity does not exist")) {
// row was deleted; recover or remove the variable
runtimeService.removeVariable(executionId, "order");
} else { throw e; }
} Prevention
- Do not delete rows referenced by running process instances
- Use soft deletes for entities used as process variables
- Verify the engine's EntityManagerFactory datasource per environment
When it happens
Trigger: Reading a JPA entity process variable whose underlying database row was deleted between variable creation and lookup; wrong EntityManagerFactory/persistence unit configured so find runs against another database.
Common situations: Entity purged by a cleanup job while the process instance still references it; pointing the engine at a different datasource in another environment (test vs prod); entity deleted by a cascade or manual SQL.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Entity does not exist: ${entityClass} - ${primaryKey}
- No decision table found with id ${decisionTableId}
- Lock with name ${lockName} does not exist
- Error while flushing EntityManager:
- Error while flushing EntityManager: " + pe.getMessage()
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/ba491bc7e6fd0e65.
Report an issue: GitHub.