{"record":{"id":"52e55d9c472a9e02","repo":"flowable/flowable-engine","slug":"couldn-t-find-constructor-for-classname-with-ar","errorCode":null,"errorMessage":"couldn't find constructor for ${className} with args ${Arrays.asList(args)}","messagePattern":"couldn't find constructor for (.+?) with args (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/util/ReflectUtil.java","lineNumber":280,"sourceCode":"    private static Method findMethod(Class<? extends Object> clazz, String methodName, Object[] args) {\n        for (Method method : clazz.getDeclaredMethods()) {\n            // TODO add parameter matching\n            if (method.getName().equals(methodName) && matches(method.getParameterTypes(), args)) {\n                return method;\n            }\n        }\n        Class<?> superClass = clazz.getSuperclass();\n        if (superClass != null) {\n            return findMethod(superClass, methodName, args);\n        }\n        return null;\n    }\n\n    public static Object instantiate(String className, Object[] args) {\n        Class<?> clazz = loadClass(className);\n        Constructor<?> constructor = findMatchingConstructor(clazz, args);\n        if (constructor == null) {\n            throw new FlowableException(\"couldn't find constructor for \" + className + \" with args \" + Arrays.asList(args));\n        }\n        try {\n            return constructor.newInstance(args);\n        } catch (Exception e) {\n            throw new FlowableException(\"couldn't find constructor for \" + className + \" with args \" + Arrays.asList(args), e);\n        }\n    }\n\n    @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n    protected static <T> Constructor<T> findMatchingConstructor(Class<T> clazz, Object[] args) {\n        for (Constructor constructor : clazz.getDeclaredConstructors()) { // cannot use <?> or <T> due to JDK 5/6 incompatibility\n            if (matches(constructor.getParameterTypes(), args)) {\n                return constructor;\n            }\n        }\n        return null;\n    }\n","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/util/ReflectUtil.java#L262-L298","documentation":"Thrown when ReflectUtil.instantiate cannot locate any declared constructor on the class matching the supplied argument list. No object is created; Flowable aborts with this message listing the class name and arguments.","triggerScenarios":"instantiate(className, args) is called where findMatchingConstructor returns null — no declared constructor of the loaded class accepts the given argument types/arity.","commonSituations":"Custom class configured for engine (e.g. custom job handler, variable type) lacking the expected constructor; class refactored and constructor signature changed; wrong class name string pointing to a different class.","solutions":["Verify the class name string points to the intended class (check for typos/old FQCN)","Add a constructor accepting exactly the argument types passed to instantiate","Change the arguments to match an existing constructor","Check for class shadowing — an unexpected version of the class may be on the classpath"],"exampleFix":"// before\npublic MyDelegate(String cfg) { ... } // invoked with instantiate(\"MyDelegate\", new Object[]{ 42 })\n// after\npublic MyDelegate(Object cfg) { ... } // or pass matching args: instantiate(\"MyDelegate\", new Object[]{ \"cfg\" })","handlingStrategy":"validation","validationCode":"Class<?> clazz = Class.forName(className);\nboolean match = Arrays.stream(clazz.getDeclaredConstructors())\n    .anyMatch(c -> c.getParameterCount() == args.length);\nif (!match) throw new IllegalStateException(\"no matching constructor on \" + className);","typeGuard":null,"tryCatchPattern":"try {\n    Object o = ReflectUtil.instantiate(className, args);\n} catch (FlowableException e) {\n    throw new IllegalStateException(\"Check configured class and its constructors: \" + className, e);\n}","preventionTips":["Verify configured class names (FQCN) for typos","Provide a no-arg constructor on custom delegate/handler classes","Recheck constructor signatures after refactoring custom classes"],"tags":["reflection","constructor","class-not-found"],"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-14T11:17:12.474Z"}