{"record":{"id":"edc993711324a2fb","repo":"flowable/flowable-engine","slug":"task-form-definition-for-not-found","errorCode":null,"errorMessage":"Task form definition for '' not found","messagePattern":"Task form definition for '' not found","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetRenderedTaskFormCmd.java","lineNumber":52,"sourceCode":"    protected String taskId;\n    protected String formEngineName;\n\n    public GetRenderedTaskFormCmd(String taskId, String formEngineName) {\n        this.taskId = taskId;\n        this.formEngineName = formEngineName;\n    }\n\n    @Override\n    public Object execute(CommandContext commandContext) {\n        TaskEntity task = commandContext\n                .getTaskEntityManager()\n                .findTaskById(taskId);\n        if (task == null) {\n            throw new ActivitiObjectNotFoundException(\"Task '\" + taskId + \"' not found\", Task.class);\n        }\n\n        if (task.getTaskDefinition() == null) {\n            throw new ActivitiException(\"Task form definition for '\" + taskId + \"' not found\");\n        }\n\n        TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();\n        if (taskFormHandler == null) {\n            return null;\n        }\n\n        FormEngine formEngine = commandContext\n                .getProcessEngineConfiguration()\n                .getFormEngines()\n                .get(formEngineName);\n\n        if (formEngine == null) {\n            throw new ActivitiException(\"No formEngine '\" + formEngineName + \"' defined process engine configuration\");\n        }\n\n        TaskFormData taskForm = taskFormHandler.createTaskForm(task);\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetRenderedTaskFormCmd.java#L34-L70","documentation":"Thrown when the task exists but its task definition is null, meaning the task was not created from a parsed BPMN task definition (task.getTaskDefinition() == null), so no task form handler/definition is available.","triggerScenarios":"Rendering a form for a task whose TaskEntity was created without a TaskDefinition — e.g. standalone/ad-hoc tasks created via TaskService.newTask() that are not bound to a BPMN element with form metadata.","commonSituations":"Creating tasks programmatically with taskService.newTask() and then attempting to render their forms; process definitions where the target task element lacks form definition data; data migrated between engine versions leaving tasks without definitions.","solutions":["Only request rendered forms for tasks created by a process execution (bound to a BPMN user task element).","For ad-hoc tasks, skip form rendering and present a generic UI.","Check the BPMN XML defines the user task properly so the TaskDefinition is populated at parse time.","Verify the deployment containing the user task is the one that started the process instance."],"exampleFix":"// before\ntaskService.getRenderedTaskForm(adHocTask.getId()); // task has no definition\n// after\nif (task.getProcessDefinitionId() != null) {\n    taskService.getRenderedTaskForm(task.getId());\n} else {\n    // render a default form for standalone tasks\n}","handlingStrategy":"type-guard","validationCode":"Task task = taskService.createTaskQuery().taskId(taskId).singleResult();\nboolean hasDefinition = task != null && task.getProcessDefinitionId() != null;","typeGuard":"boolean isProcessBoundTask(Task task) {\n    return task != null && task.getProcessDefinitionId() != null;\n}","tryCatchPattern":"try {\n    taskService.getRenderedTaskForm(taskId);\n} catch (ActivitiException e) {\n    if (e.getMessage().startsWith(\"Task form definition for\")) {\n        // render generic form for ad-hoc task\n    }\n}","preventionTips":["Only request forms for tasks created from BPMN user task elements","Define form metadata in the BPMN for every user task you want forms for","Keep deployments in sync with running instances so task definitions parse correctly"],"tags":["task","form-definition","workflow"],"backgroundTag":"entity-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}