{"record":{"id":"2568b450b2d22536","repo":"flowable/flowable-engine","slug":"could-not-get-context-class-loader","errorCode":null,"errorMessage":"Could not get context class loader","messagePattern":"Could not get context class loader","errorType":"exception","errorClass":"ELException","httpStatus":null,"severity":"warning","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/ExpressionFactoryImpl.java","lineNumber":422,"sourceCode":"\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 {\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","sourceCodeStart":404,"sourceCodeEnd":440,"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#L404-L440","documentation":"load() resolves a class named in the factory properties and tries to use the thread context class loader (TCCL) to load it. If obtaining the TCCL itself throws (rare: security manager or unusual threading environment), it wraps the exception in ELException 'Could not get context class loader'.","triggerScenarios":"ExpressionFactoryImpl.load() (accessed via the clazz() accessor while resolving property-configured classes) calls Thread.currentThread().getContextClassLoader() and the call throws — typically under a restrictive Java SecurityManager or a container that denies RuntimePermission 'getClassLoader'.","commonSituations":"Running inside an application server or sandbox with a SecurityManager that blocks context classloader access; exotic custom thread implementations whose getContextClassLoader throws.","solutions":["Grant RuntimePermission(\"getClassLoader\") to the application's security policy","Remove or relax the SecurityManager restrictions for the engine's execution context","Set the factory classes explicitly so they resolve without context-loader lookup, or run with a standard thread context"],"exampleFix":"// before (java.policy)\ngrant { };\n\n// after\ngrant {\n  permission java.lang.RuntimePermission \"getClassLoader\";\n};","handlingStrategy":"try-catch","validationCode":"try {\n    ClassLoader l = Thread.currentThread().getContextClassLoader();\n} catch (SecurityException e) {\n    throw new IllegalStateException(\"Security policy denies getClassLoader; grant RuntimePermission before engine init\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ExpressionFactory factory = new ExpressionFactoryImpl();\n} catch (ELException e) {\n    if (e.getMessage().contains(\"Could not get context class loader\")) {\n        throw new IllegalStateException(\"Review SecurityManager policy: getClassLoader permission required\", e);\n    }\n    throw e;\n}","preventionTips":["Audit java.policy grants when running with a SecurityManager","Test engine startup under the target container's security configuration","Avoid exotic Thread subclasses that override getContextClassLoader"],"tags":["classloader","security","el","reflection","flowable"],"backgroundTag":"permission-denied","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"}