{"record":{"id":"201f603aaf771c35","repo":"flowable/flowable-engine","slug":"class-classname-could-not-be-instantiated","errorCode":null,"errorMessage":"Class ${className} could not be instantiated","messagePattern":"Class (.+?) 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":429,"sourceCode":"\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 {\n\t\t\t\t\treturn loader == null ? Class.forName(className) : loader.loadClass(className);\n\t\t\t\t} catch (ClassNotFoundException e) {\n\t\t\t\t\tthrow new ELException(\"Class \" + className + \" not found\", e);\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tthrow new ELException(\"Class \" + className + \" could not be instantiated\", e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic final <T> T coerceToType(Object obj, Class<T> targetType) {\n\t\treturn converter.convert(obj, targetType);\n\t}\n\n\t@Override\n\tpublic final ObjectValueExpression createValueExpression(Object instance, Class<?> expectedType) {\n\t\treturn new ObjectValueExpression(converter, instance, expectedType);\n\t}\n\n\t@Override\n\tpublic final TreeValueExpression createValueExpression(ELContext context, String expression, Class<?> expectedType) {","sourceCodeStart":411,"sourceCodeEnd":447,"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#L411-L447","documentation":"Thrown by the EL implementation's class-loading helper (ExpressionFactoryImpl.load) when the class for a given className was found and loaded but could not be instantiated (any exception other than ClassNotFoundException). The library wraps the underlying reflective instantiation failure (e.g. missing public no-arg constructor, constructor threw, or illegal access) in an ELException with this message.","triggerScenarios":"An EL expression or type reference causes load(className) to be invoked; Class.forName/loadClass succeeds but instantiating the class fails because the class has no accessible no-arg constructor, its constructor throws, or it is abstract/interface.","commonSituations":"Custom FunctionMapper/ELResolver entries or expression operands naming a class whose implementation changed between versions; referencing an abstract class or interface in an expression; a class with initialization code that fails at static-init time in the target environment.","solutions":["Check the cause chained in the ELException: it names the exact instantiation problem (NoSuchMethodException, InstantiationException, InvocationTargetException).","Ensure the referenced class is public, concrete (not abstract/interface), and has a public no-arg constructor.","Fix any static initializer or constructor code that throws in the deployment environment (missing config, dependencies).","Verify the class name string in the expression/config matches an existing class on the classpath for the current library version."],"exampleFix":"// before: expression references abstract type\nfoo = com.example.AbstractHandler\n// after: reference a concrete, no-arg-constructible class\nfoo = com.example.DefaultHandler","handlingStrategy":"try-catch","validationCode":"Class<?> c = Class.forName(className);\nif (c.isInterface() || Modifier.isAbstract(c.getModifiers())) throw new IllegalArgumentException(className + \" is not instantiable\");\nc.getDeclaredConstructor(); // fails fast if no no-arg constructor","typeGuard":"boolean isInstantiable(Class<?> c) {\n    return c != null && !c.isInterface() && !Modifier.isAbstract(c.getModifiers())\n        && java.util.Arrays.stream(c.getConstructors()).anyMatch(k -> k.getParameterCount() == 0 && Modifier.isPublic(k.getModifiers()));\n}","tryCatchPattern":"try {\n    Object o = expression.eval(context);\n} catch (ELException e) {\n    Throwable cause = e.getCause();\n    log.error(\"Class instantiation failed: {}\", cause != null ? cause.toString() : e.getMessage(), e);\n}","preventionTips":["Only reference public concrete classes with public no-arg constructors in EL expressions.","Check e.getCause() of ELException for the exact reflective failure.","Keep class names in configuration in sync with refactors between library versions.","Avoid static-initializer code that can throw in restricted environments."],"tags":["el","reflection","classloading","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"}