flowable/flowable-engine · warning
com.sun.management.ThreadMXBean was not found on the…
Error message
com.sun.management.ThreadMXBean was not found on the classpath. This means that the limiting the memory usage for a script will NOT work.
What it means
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.
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.
Example fix
// before
secureScriptContextFactory.setMaxMemoryUsed(10 * 1024 * 1024);
// after: only when com.sun.management is present
if (SecureScriptContextFactory.isMemoryLimitSupported()) {
secureScriptContextFactory.setMaxMemoryUsed(10 * 1024 * 1024);
} Defensive patterns
Strategy: type-guard
Validate before calling
boolean memoryLimitSupported;
try {
Class.forName("com.sun.management.ThreadMXBean");
memoryLimitSupported = true;
} catch (ClassNotFoundException e) {
memoryLimitSupported = false;
} Type guard
static boolean canLimitScriptMemory() {
try { return Class.forName("com.sun.management.ThreadMXBean") != null; }
catch (Throwable t) { return false; }
} Prevention
- 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.
When it happens
Trigger: setMaxMemoryUsed is called on SecureScriptContextFactory and Class.forName("com.sun.management.ThreadMXBean") throws ClassNotFoundException.
Common situations: 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.
Related errors
- BPMN XSD could not be found
- Can't find scripting engine for
- Cannot read default EL properties
- Class not found
- Class has not been found.
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/80b174576cd4efa6.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-secure-javascript/src/main/java/org/flowable/scripting/secure/impl/SecureScriptContextFactory.java:152
public void setMaxScriptExecutionTime(long maxScriptExecutionTime) {
this.maxScriptExecutionTime = maxScriptExecutionTime;
}
public long getMaxMemoryUsed() {
return maxMemoryUsed;
}
public void setMaxMemoryUsed(long maxMemoryUsed) {
this.maxMemoryUsed = maxMemoryUsed;
if (maxMemoryUsed > 0) {
try {
Class clazz = Class.forName("com.sun.management.ThreadMXBean");
if (clazz != null) {
this.threadMxBeanWrapper = new SecureScriptThreadMxBeanWrapper();
}
} catch (ClassNotFoundException cnfe) {
LOGGER.warn("com.sun.management.ThreadMXBean was not found on the classpath. " +
"This means that the limiting the memory usage for a script will NOT work.");
}
}
}
public int getMaxStackDepth() {
return maxStackDepth;
}
public void setMaxStackDepth(int maxStackDepth) {
this.maxStackDepth = maxStackDepth;
}
public boolean isEnableAccessToBeans() {
return enableAccessToBeans;
}
public void setEnableAccessToBeans(boolean enableAccessToBeans) {View on GitHub (pinned to d6d39ce1c6)