{"record":{"id":"80b174576cd4efa6","repo":"flowable/flowable-engine","slug":"com-sun-management-threadmxbean-was-not-found-on-t","errorCode":null,"errorMessage":"com.sun.management.ThreadMXBean was not found on the classpath. This means that the limiting the memory usage for a script will NOT work.","messagePattern":"com\\.sun\\.management\\.ThreadMXBean was not found on the classpath\\. This means that the limiting the memory usage for a script will NOT work\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/flowable-secure-javascript/src/main/java/org/flowable/scripting/secure/impl/SecureScriptContextFactory.java","lineNumber":152,"sourceCode":"\n    public void setMaxScriptExecutionTime(long maxScriptExecutionTime) {\n        this.maxScriptExecutionTime = maxScriptExecutionTime;\n    }\n\n    public long getMaxMemoryUsed() {\n        return maxMemoryUsed;\n    }\n\n    public void setMaxMemoryUsed(long maxMemoryUsed) {\n        this.maxMemoryUsed = maxMemoryUsed;\n        if (maxMemoryUsed > 0) {\n            try {\n                Class clazz = Class.forName(\"com.sun.management.ThreadMXBean\");\n                if (clazz != null) {\n                    this.threadMxBeanWrapper = new SecureScriptThreadMxBeanWrapper();\n                }\n            } catch (ClassNotFoundException cnfe) {\n                LOGGER.warn(\"com.sun.management.ThreadMXBean was not found on the classpath. \" +\n                        \"This means that the limiting the memory usage for a script will NOT work.\");\n            }\n        }\n    }\n\n    public int getMaxStackDepth() {\n        return maxStackDepth;\n    }\n\n    public void setMaxStackDepth(int maxStackDepth) {\n        this.maxStackDepth = maxStackDepth;\n    }\n\n    public boolean isEnableAccessToBeans() {\n        return enableAccessToBeans;\n    }\n\n    public void setEnableAccessToBeans(boolean enableAccessToBeans) {","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-secure-javascript/src/main/java/org/flowable/scripting/secure/impl/SecureScriptContextFactory.java#L134-L170","documentation":"SecureJavascriptTaskActivityBehavior can limit a script's memory usage by instrumenting thread allocation via com.sun.management.ThreadMXBean (a JDK-internal API). When that class is absent — e.g. running on a JRE without the com.sun.management package or a non-HotSpot JVM — the limit silently cannot be enforced and this warning is logged.","triggerScenarios":"setMaxMemoryUsed is called on SecureScriptContextFactory and Class.forName(\"com.sun.management.ThreadMXBean\") throws ClassNotFoundException.","commonSituations":"Running Flowable on an IBM J9/OpenJ9 JVM, a stripped JRE, or a newer JDK configuration lacking the com.sun.management ThreadMXBean implementation; containerized images using jlink minimal runtimes.","solutions":["Run on a HotSpot-based JDK that includes com.sun.management.ThreadMXBean (standard Oracle/OpenJDK full JDK).","Accept the warning and disable memory limiting (do not call setMaxMemoryUsed / remove the memory-limit config) since it has no effect.","Fall back to limiting script execution via maxScriptStackDepth / execution time limits instead of memory.","If using a jlink runtime, include the jdk.management module which provides com.sun.management."],"exampleFix":"// before\nsecureScriptContextFactory.setMaxMemoryUsed(10 * 1024 * 1024);\n// after: only when com.sun.management is present\nif (SecureScriptContextFactory.isMemoryLimitSupported()) {\n    secureScriptContextFactory.setMaxMemoryUsed(10 * 1024 * 1024);\n}","handlingStrategy":"type-guard","validationCode":"boolean memoryLimitSupported;\ntry {\n    Class.forName(\"com.sun.management.ThreadMXBean\");\n    memoryLimitSupported = true;\n} catch (ClassNotFoundException e) {\n    memoryLimitSupported = false;\n}","typeGuard":"static boolean canLimitScriptMemory() {\n    try { return Class.forName(\"com.sun.management.ThreadMXBean\") != null; }\n    catch (Throwable t) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Run Flowable on a full OpenJDK/HotSpot JDK with the jdk.management module.","Only configure script memory limits when ThreadMXBean is available.","Use stack-depth/time limits as fallback controls on restricted JVMs."],"tags":["jvm","javascript","memory-limit","classpath"],"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-18T11:17:12.947Z"}