pinpoint-apm/pinpoint · error · IllegalStateException

OperatingSystemMXBean not available

Error message

OperatingSystemMXBean not available

What it means

DefaultCpuLoadMetric for Oracle/HotSpot JDKs casts the platform OperatingSystemMXBean to com.sun.management.OperatingSystemMXBean and throws IllegalStateException if the bean is null. It guards construction of JVM CPU usage providers, meaning the JDK does not expose the expected com.sun.management MXBean.

Source

Thrown at agent-module/profiler-optional/profiler-optional-jdk8/src/main/java/com/navercorp/pinpoint/profiler/monitor/metric/cpu/oracle/DefaultCpuLoadMetric.java:41

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.lang.management.ManagementFactory;

/**
 * @author HyunGil Jeong
 */
public class DefaultCpuLoadMetric implements CpuLoadMetric {

    private final Logger logger = LogManager.getLogger(this.getClass());

    private final CpuUsageProvider jvmCpuUsageProvider;
    private final CpuUsageProvider systemCpuUsageProvider;

    public DefaultCpuLoadMetric() {
        final OperatingSystemMXBean operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
        if (operatingSystemMXBean == null) {
            throw new IllegalStateException("OperatingSystemMXBean not available");
        }

        CpuUsageProvider jvmCpuUsageProvider = new JvmCpuUsageProvider(operatingSystemMXBean);
        try {
            jvmCpuUsageProvider.getCpuUsage();
        } catch (NoSuchMethodError e) {
            logger.warn("Expected method not found for retrieving jvm cpu usage. Cause : {}", e.getMessage());
            jvmCpuUsageProvider = CpuUsageProvider.UNSUPPORTED;
        }
        this.jvmCpuUsageProvider = jvmCpuUsageProvider;

        CpuUsageProvider systemCpuUsageProvider = new SystemCpuUsageProvider(operatingSystemMXBean);
        try {
            systemCpuUsageProvider.getCpuUsage();
        } catch (NoSuchMethodError e) {
            logger.warn("Expected method not found for retrieving system cpu usage. Cause : {}", e.getMessage());
            systemCpuUsageProvider = CpuUsageProvider.UNSUPPORTED;
        }

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Run on a HotSpot/Oracle/OpenJDK JVM that implements com.sun.management.OperatingSystemMXBean
  2. Use the IBM or vendor-appropriate DefaultCpuLoadMetric module instead
  3. Disable the Oracle CpuLoadMetric plugin on non-HotSpot JVMs
  4. Check ManagementFactory.getOperatingSystemMXBean() class before enabling the plugin

Example fix

// before
new DefaultCpuLoadMetric(); // assumes HotSpot
// after
if (ManagementFactory.getOperatingSystemMXBean() instanceof com.sun.management.OperatingSystemMXBean) {
    metric = new DefaultCpuLoadMetric();
} else {
    metric = new UnsupportedCpuLoadMetric();
}
Defensive patterns

Strategy: validation

Validate before calling

Object bean = ManagementFactory.getOperatingSystemMXBean();
boolean hotspotOk = bean instanceof com.sun.management.OperatingSystemMXBean;

Type guard

boolean isHotSpotOperatingSystemMXBean(OperatingSystemMXBean b) {
    return b instanceof com.sun.management.OperatingSystemMXBean;
}

Prevention

When it happens

Trigger: Constructing com.navercorp.pinpoint.profiler.monitor.metric.cpu.oracle.DefaultCpuLoadMetric when ManagementFactory.getOperatingSystemMXBean() is null or is not a com.sun.management.OperatingSystemMXBean (e.g. IBM J9, JRockit, or hardened JVMs).

Common situations: Running the agent on IBM/OpenJ9 or other non-HotSpot JVMs while the Oracle metric module is loaded; unusual JVM implementations lacking com.sun.management APIs; vendor-detection mistakes in plugin selection.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/c73992329a201274. Report an issue: GitHub.