{"record":{"id":"96f4d8c7a8e89aad","repo":"flowable/flowable-engine","slug":"could-not-instantiate-businessruletask-id-bus","errorCode":null,"errorMessage":"Could not instantiate businessRuleTask (id:\" + businessRuleTask.getId() + \") class: \" + businessRuleTask.getClassName()","messagePattern":"Could not instantiate businessRuleTask \\(id:\" \\+ businessRuleTask\\.getId\\(\\) \\+ \"\\) class: \" \\+ businessRuleTask\\.getClassName\\(\\)","errorType":"validation","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/factory/DefaultActivityBehaviorFactory.java","lineNumber":392,"sourceCode":"        } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(serviceTask.getImplementationType())) {\n            return createServiceTaskDelegateExpressionActivityBehavior(serviceTask);\n        } else {\n            return classDelegateFactory.create(serviceTask.getId(), DefaultBpmnHttpActivityDelegate.class.getName(),\n                    createFieldDeclarations(serviceTask.getFieldExtensions()),\n                    serviceTask.isTriggerable(),\n                    getSkipExpressionFromServiceTask(serviceTask), serviceTask.getMapExceptions());\n        }\n    }\n\n    @Override\n    public ActivityBehavior createBusinessRuleTaskActivityBehavior(BusinessRuleTask businessRuleTask) {\n        BusinessRuleTaskDelegate ruleActivity = null;\n        if (StringUtils.isNotEmpty(businessRuleTask.getClassName())) {\n            try {\n                Class<?> clazz = Class.forName(businessRuleTask.getClassName());\n                ruleActivity = (BusinessRuleTaskDelegate) clazz.getConstructor().newInstance();\n            } catch (Exception e) {\n                throw new FlowableException(\"Could not instantiate businessRuleTask (id:\" + businessRuleTask.getId() + \") class: \" +\n                        businessRuleTask.getClassName(), e);\n            }\n        } else {\n            ruleActivity = new BusinessRuleTaskActivityBehavior();\n        }\n\n        for (String ruleVariableInputObject : businessRuleTask.getInputVariables()) {\n            ruleActivity.addRuleVariableInputIdExpression(expressionManager.createExpression(ruleVariableInputObject.trim()));\n        }\n\n        for (String rule : businessRuleTask.getRuleNames()) {\n            ruleActivity.addRuleIdExpression(expressionManager.createExpression(rule.trim()));\n        }\n\n        ruleActivity.setExclude(businessRuleTask.isExclude());\n\n        if (businessRuleTask.getResultVariableName() != null && businessRuleTask.getResultVariableName().length() > 0) {\n            ruleActivity.setResultVariable(businessRuleTask.getResultVariableName());","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/factory/DefaultActivityBehaviorFactory.java#L374-L410","documentation":"createBusinessRuleTaskActivityBehavior instantiates a custom BusinessRuleTaskDelegate class given by businessRuleTask.getClassName() via reflection. Any failure in loading, constructing (no-arg constructor required), or casting throws FlowableException(\"Could not instantiate businessRuleTask (id:...) class:...\") with the cause attached.","triggerScenarios":"A business rule task declares flowable:class=\"...\" whose class cannot be loaded (not on classpath, wrong name), has no public no-arg constructor, or does not implement BusinessRuleTaskDelegate.","commonSituations":"Typo in fully-qualified class name; class compiled against a different Flowable version; custom rule task lacking a no-arg constructor; deployment classloader not seeing the application class.","solutions":["Verify the class name in the BPMN XML is correct and the class is on the engine classpath","Ensure the class implements BusinessRuleTaskDelegate and has a public no-arg constructor","Check getCause() of the exception to distinguish ClassNotFoundException vs InstantiationException/ClassCastException","If no custom class is needed, remove the flowable:class attribute so the default BusinessRuleTaskActivityBehavior is used"],"exampleFix":"// before\npublic class MyRuleTask {\n    public MyRuleTask(String config) { ... }\n}\n// after\npublic class MyRuleTask implements BusinessRuleTaskDelegate {\n    public MyRuleTask() { }\n    public void execute(DelegateExecution execution) { ... }\n}","handlingStrategy":"validation","validationCode":"Class<?> c = Class.forName(className);\nif (!BusinessRuleTaskDelegate.class.isAssignableFrom(c)) throw new IllegalStateException(className + \" must implement BusinessRuleTaskDelegate\");\nif (c.getConstructor() == null) throw new IllegalStateException(className + \" needs a public no-arg constructor\");","typeGuard":null,"tryCatchPattern":"try {\n    repositoryService.createDeployment().deploy();\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"Could not instantiate businessRuleTask\")) {\n        log.error(\"Check class name, no-arg constructor and BusinessRuleTaskDelegate interface. Cause:\", e.getCause());\n    }\n}","preventionTips":["Implement BusinessRuleTaskDelegate and provide a public no-arg constructor","Keep the custom rule task's Flowable version aligned with the engine","Unit-test reflective instantiation of custom task classes before deployment"],"tags":["bpmn","reflection","instantiation"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}