{"record":{"id":"b479c3888ad2d815","repo":"flowable/flowable-engine","slug":"treebuilder-clazz-could-not-be-instantiated","errorCode":null,"errorMessage":"TreeBuilder ${clazz} could not be instantiated","messagePattern":"TreeBuilder (.+?) could not be instantiated","errorType":"exception","errorClass":"ELException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/ExpressionFactoryImpl.java","lineNumber":406,"sourceCode":"\t\t\treturn createDefaultTreeBuilder(features);\n\t\t}\n\t\ttry {\n\t\t\tif (Builder.class.isAssignableFrom(clazz)) {\n\t\t\t\tConstructor<?> constructor = clazz.getConstructor(Feature[].class);\n\t\t\t\tif (constructor == null) {\n\t\t\t\t\tif (features == null || features.length == 0) {\n\t\t\t\t\t\treturn TreeBuilder.class.cast(clazz.newInstance());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ELException(\"Builder \" + clazz + \" is missing constructor (can't pass features)\");\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn TreeBuilder.class.cast(constructor.newInstance((Object) features));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn TreeBuilder.class.cast(clazz.newInstance());\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tthrow new ELException(\"TreeBuilder \" + clazz + \" could not be instantiated\", e);\n\t\t}\n\t}\n\n\tprotected TreeBuilder createDefaultTreeBuilder(Feature... features) {\n\t\treturn new Builder(features);\n\t}\n\n\tprivate Class<?> load(Class<?> clazz, Properties properties) {\n\t\tif (properties != null) {\n\t\t\tString className = properties.getProperty(clazz.getName());\n\t\t\tif (className != null) {\n\t\t\t\tClassLoader loader;\n\t\t\t\ttry {\n\t\t\t\t\tloader = Thread.currentThread().getContextClassLoader();\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tthrow new ELException(\"Could not get context class loader\", e);\n\t\t\t\t}\n\t\t\t\ttry {","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/ExpressionFactoryImpl.java#L388-L424","documentation":"createTreeBuilder() instantiates the configured TreeBuilder class reflectively at the end of its dispatch (either via the Feature[] constructor or clazz.newInstance()). Any reflection failure (instantiation exception, access violation, etc.) is wrapped as ELException 'TreeBuilder X could not be instantiated'.","triggerScenarios":"ExpressionFactoryImpl creation with PROP_TREE_BUILDER naming a class that cannot be instantiated: no accessible no-arg constructor, abstract class, constructor throws, or security/visibility restrictions.","commonSituations":"Typo or wrong class name in the tree-builder property; custom builder with required constructor arguments; builder class failing in static/instance initialization due to missing dependencies.","solutions":["Ensure the configured TreeBuilder class is concrete with a public no-arg (or Feature[]) constructor","Check the class name in the properties for typos and that the class is on the classpath","Remove the tree-builder property to use the default Builder"],"exampleFix":"// before\nprops.setProperty(\"de.odysseus.el.TreeBuilder\", \"com.acme.MyTreeBuilder\"); // abstract\n\n// after\nprops.setProperty(\"de.odysseus.el.TreeBuilder\", \"com.acme.ConcreteTreeBuilder\");","handlingStrategy":"validation","validationCode":"String name = props.getProperty(\"de.odysseus.el.TreeBuilder\");\nif (name != null) {\n    Class<?> c = Class.forName(name);\n    if (c.isInterface() || Modifier.isAbstract(c.getModifiers())) {\n        throw new IllegalStateException(\"TreeBuilder must be a concrete class: \" + name);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    ExpressionFactory factory = new ExpressionFactoryImpl(props);\n} catch (ELException e) {\n    if (e.getMessage().contains(\"TreeBuilder\") && e.getMessage().contains(\"could not be instantiated\")) {\n        log.error(\"Cannot instantiate configured TreeBuilder: check class and constructors\", e);\n    }\n    throw e;\n}","preventionTips":["Keep TreeBuilder property values in sync with the codebase (rename refactors)","Use the default Builder unless a custom one is truly required","Cover factory construction in an integration smoke test"],"tags":["reflection","el","instantiation","configuration","flowable"],"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-14T05:17:10.506Z"}