{"record":{"id":"ecfd77c075297e71","repo":"flowable/flowable-engine","slug":"couldn-t-instantiate-implementationclass-getna","errorCode":null,"errorMessage":"couldn't instantiate \" + implementationClass.getName() + \": \" + e.getMessage()","messagePattern":"couldn't instantiate \" \\+ implementationClass\\.getName\\(\\) \\+ \": \" \\+ e\\.getMessage\\(\\)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/GenericManagerFactory.java","lineNumber":51,"sourceCode":"    public GenericManagerFactory(Class<? extends Session> typeClass, Supplier<? extends Session> sessionCreator) {\n        this(typeClass, context -> sessionCreator.get());\n    }\n\n    public GenericManagerFactory(Class<? extends Session> typeClass, Function<CommandContext, ? extends Session> sessionCreator) {\n        this.typeClass = typeClass;\n        this.sessionCreator = sessionCreator;\n    }\n\n    /**\n     * @deprecated use {@link #GenericManagerFactory(Class, Supplier)} instead\n     */\n    @Deprecated\n    public GenericManagerFactory(Class<? extends Session> typeClass, Class<? extends Session> implementationClass) {\n        this(typeClass, commandContext -> {\n            try {\n                return implementationClass.getConstructor().newInstance();\n            } catch (Exception e) {\n                throw new FlowableException(\"couldn't instantiate \" + implementationClass.getName() + \": \" + e.getMessage(), e);\n            }\n        });\n    }\n\n    /**\n     * @deprecated use {@link #GenericManagerFactory(Class, Supplier)} instead\n     */\n    @Deprecated\n    public GenericManagerFactory(Class<? extends Session> implementationClass) {\n        this(implementationClass, implementationClass);\n    }\n\n    @Override\n    public Class<?> getSessionType() {\n        return typeClass;\n    }\n\n    @Override","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/GenericManagerFactory.java#L33-L69","documentation":"This deprecated GenericManagerFactory constructor instantiates the session implementation class reflectively via its no-arg constructor. If instantiation fails (no public no-arg constructor, abstract class, constructor throws), it wraps the failure in a FlowableException naming the class and the underlying message.","triggerScenarios":"Calling the deprecated constructor GenericManagerFactory(typeClass, implementationClass) where implementationClass lacks an accessible no-arg constructor, is abstract/an interface, or whose constructor throws an exception.","commonSituations":"Custom session/manager implementations that require constructor dependencies; wiring an interface or abstract class by mistake; upgrading Flowable where a manager class gained required constructor arguments.","solutions":["Use the non-deprecated GenericManagerFactory(Class, Supplier) constructor, e.g. new GenericManagerFactory<>(MySession.class, MySession::new)","Ensure the implementation class has a public no-arg constructor and is concrete","If dependencies are needed, use the supplier variant to construct it with arguments"],"exampleFix":"// before\nnew GenericManagerFactory<>(MySession.class, MySessionImpl.class);\n// after\nnew GenericManagerFactory<>(MySession.class, () -> new MySessionImpl(depA, depB));","handlingStrategy":"try-catch","validationCode":"// check the implementation class is instantiable\nClass<?> c = implementationClass;\nif (c.isInterface() || java.lang.reflect.Modifier.isAbstract(c.getModifiers()))\n    throw new IllegalArgumentException(\"must be concrete\");\nc.getDeclaredConstructor(); // throws NoSuchMethodException if no no-arg ctor","typeGuard":null,"tryCatchPattern":"try {\n    new GenericManagerFactory<>(MySession.class, MySessionImpl.class);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"couldn't instantiate\")) {\n        // fall back to supplier-based factory\n    }\n    throw e;\n}","preventionTips":["Prefer the Supplier-based GenericManagerFactory constructor","Keep session implementations concrete with public no-arg constructors","Handle constructor failures explicitly in the supplier"],"tags":["reflection","instantiation","deprecated"],"backgroundTag":"class-instantiation-failed","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"}