{"record":{"id":"63be6dbf36749f8c","repo":"flowable/flowable-engine","slug":"object-is-not-a-jpa-entity-class-value-getclas","errorCode":null,"errorMessage":"Object is not a JPA Entity: class='${value.getClass()}', ${value}","messagePattern":"Object is not a JPA Entity: class='(.+?)', (.+?)","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/variable/JPAEntityMappings.java","lineNumber":76,"sourceCode":"            // Class not present in meta-data map, create metaData for it and add\n            metaData = scanClass(clazz);\n            classMetaDatamap.put(clazz.getName(), metaData);\n        }\n        return metaData;\n    }\n\n    private EntityMetaData scanClass(Class<?> clazz) {\n        return enitityScanner.scanClass(clazz);\n    }\n\n    public String getJPAClassString(Object value) {\n        if (value == null) {\n            throw new ActivitiIllegalArgumentException(\"null value cannot be saved\");\n        }\n\n        EntityMetaData metaData = getEntityMetaData(value.getClass());\n        if (!metaData.isJPAEntity()) {\n            throw new ActivitiIllegalArgumentException(\"Object is not a JPA Entity: class='\" + value.getClass() + \"', \" + value);\n        }\n\n        // Extract the class from the Entity instance\n        return metaData.getEntityClass().getName();\n    }\n\n    public String getJPAIdString(Object value) {\n        EntityMetaData metaData = getEntityMetaData(value.getClass());\n        if (!metaData.isJPAEntity()) {\n            throw new ActivitiIllegalArgumentException(\"Object is not a JPA Entity: class='\" + value.getClass() + \"', \" + value);\n        }\n        Object idValue = getIdValue(value, metaData);\n        return getIdString(idValue);\n    }\n\n    public Object getIdValue(Object value, EntityMetaData metaData) {\n        try {\n            if (metaData.getIdMethod() != null) {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/variable/JPAEntityMappings.java#L58-L94","documentation":"getJPAClassString validates that the value's class is annotated as a JPA entity (via EntityMetaData.isJPAEntity). If the object lacks @Entity (or valid JPA metadata), it cannot be stored as a JPA entity variable, so this error is thrown.","triggerScenarios":"Passing a plain POJO, DTO, collection, String, or an un-annotated class to a variable API that resolves to the JPA entity variable type, or an entity whose metadata scanning failed (missing @Entity annotation).","commonSituations":"Putting a DTO into a process variable while a JPA entity type was expected; forgetting @Entity on the class; entity class from another persistence unit not scanned; proxy classes (Hibernate) wrapping the entity in odd configurations.","solutions":["Annotate the class with @Entity and ensure it has a valid @Id","Verify you are storing the actual entity, not a DTO or wrapper","Check the JPA/persistence configuration so entity scanning sees the class","If a plain object is intended, do not use the JPA entity variable mapping"],"exampleFix":"// before\npublic class Order { private Long id; ... }\nruntimeService.setVariable(executionId, \"order\", new Order());\n// after\n@Entity\npublic class Order { @Id private Long id; ... }","handlingStrategy":"type-guard","validationCode":"if (!value.getClass().isAnnotationPresent(Entity.class)) {\n    throw new IllegalArgumentException(value.getClass() + \" is not a JPA entity\");\n}","typeGuard":"boolean isJpaEntity(Object v) {\n    return v != null && v.getClass().isAnnotationPresent(javax.persistence.Entity.class);\n}","tryCatchPattern":"try {\n    runtimeService.setVariable(id, \"order\", value);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Object is not a JPA Entity\")) {\n        // store as serializable instead\n        runtimeService.setVariable(id, \"order\", (Serializable) value);\n    } else { throw e; }\n}","preventionTips":["Annotate all classes stored as JPA variables with @Entity","Keep DTOs out of JPA-typed variables","Verify entity scanning configuration after package moves"],"tags":["jpa","entity-mapping","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}