{"record":{"id":"099fcb999352d9f0","repo":"flowable/flowable-engine","slug":"could-not-instantiate-businessruletask-id-busin","errorCode":null,"errorMessage":"Could not instantiate businessRuleTask (id:${businessRuleTask.getId()}) class: ${businessRuleTask.getClassName()}","messagePattern":"Could not instantiate businessRuleTask \\(id:(.+?)\\) class: (.+?)","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/factory/DefaultActivityBehaviorFactory.java","lineNumber":276,"sourceCode":"        fieldDeclarations.add(exceptionMapsFieldDeclaration);\n\n    }\n\n    @Override\n    public ShellActivityBehavior createShellActivityBehavior(ServiceTask serviceTask) {\n        List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(serviceTask.getFieldExtensions());\n        return (ShellActivityBehavior) ClassDelegate.defaultInstantiateDelegate(ShellActivityBehavior.class, fieldDeclarations);\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.newInstance();\n            } catch (Exception e) {\n                throw new ActivitiException(\"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":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/factory/DefaultActivityBehaviorFactory.java#L258-L294","documentation":"For a businessRuleTask that specifies a custom className, DefaultActivityBehaviorFactory loads the class reflectively and instantiates it as a BusinessRuleTaskDelegate. Any failure (ClassNotFoundException, instantiation errors, ClassCastException) is wrapped in this ActivitiException naming the task id and class.","triggerScenarios":"A businessRuleTask in BPMN XML declares <flowable:class>my.RuleTask</flowable:class> but the class is missing, has no public no-arg constructor, is abstract, or does not implement BusinessRuleTaskDelegate.","commonSituations":"Typos or refactors in the class name in XML; the rules task class lives in a jar not deployed with the app; class implements the wrong interface after an engine upgrade.","solutions":["Verify the className is fully qualified and present on the runtime classpath","Ensure the class has a public no-arg constructor and implements BusinessRuleTaskDelegate","Remove the className attribute to fall back to the built-in BusinessRuleTaskActivityBehavior","Check the exception cause to distinguish NotFound vs Instantiation vs Cast failures"],"exampleFix":"// before\npublic class MyRuleTask { private MyRuleTask() {} } // no accessible ctor\n// after\npublic class MyRuleTask implements BusinessRuleTaskDelegate {\n  public MyRuleTask() {}\n  // evaluateRules()/execute implementation\n}","handlingStrategy":"try-catch","validationCode":"// verify class before deploy\ntry {\n  Class<?> c = Class.forName(\"com.acme.MyRuleTask\");\n  c.getDeclaredConstructor().setAccessible(true);\n  if (!BusinessRuleTaskDelegate.class.isAssignableFrom(c))\n    throw new IllegalStateException(\"Must implement BusinessRuleTaskDelegate\");\n} catch (Exception e) { throw new IllegalStateException(\"businessRuleTask class invalid: \" + e.getMessage()); }","typeGuard":"static boolean isValidBusinessRuleClass(String className) {\n  try {\n    Class<?> c = Class.forName(className);\n    return BusinessRuleTaskDelegate.class.isAssignableFrom(c) &&\n           java.lang.reflect.Modifier.isPublic(c.getModifiers());\n  } catch (Throwable t) { return false; }\n}","tryCatchPattern":"try {\n  repositoryService.createDeployment().addClasspathResource(processXml).deploy();\n} catch (ActivitiException e) {\n  if (e.getMessage().startsWith(\"Could not instantiate businessRuleTask\")) {\n    log.error(\"bad class/ctor for task; cause:\", e.getCause());\n  }\n}","preventionTips":["Use fully qualified class names in <flowable:class> and keep them in sync via tests","Ensure a public no-arg constructor and BusinessRuleTaskDelegate implementation","Deploy the rules-task class in the same artifact as the process definitions"],"tags":["bpmn","business-rule-task","reflection","classpath"],"backgroundTag":"class-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}