pinpoint-apm/pinpoint · warning

Expected method not found for retrieving system cpu usage. C

Error message

Expected method not found for retrieving system cpu usage. Cause : {}

What it means

DefaultCpuLoadMetric probes SystemCpuUsageProvider.getCpuUsage() once at construction; on JDK 8 (and on some JVMs like older IBM/Oracle builds) OperatingSystemMXBean lacks the getSystemCpuLoad/com.sun.management method the provider expects, so a NoSuchMethodError is thrown. The metric logs this warning once and degrades the provider to CpuUsageProvider.UNSUPPORTED instead of failing startup. System CPU usage metrics will be absent, but JVM CPU metrics still work.

Source

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

        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;
        }
        this.systemCpuUsageProvider = systemCpuUsageProvider;
    }

    @Override
    public CpuLoadMetricSnapshot getSnapshot() {
        double jvmCpuUsage = jvmCpuUsageProvider.getCpuUsage();
        double systemCpuUsage = systemCpuUsageProvider.getCpuUsage();
        return new CpuLoadMetricSnapshot(jvmCpuUsage, systemCpuUsage);
    }

    @Override
    public String toString() {
        return "CpuLoadMetric for Oracle Java 1.7+";
    }

    private static class JvmCpuUsageProvider implements CpuUsageProvider {

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Verify the JDK: check that com.sun.management.OperatingSystemMXBean has getSystemCpuLoad (java -version, run 'jcmd <pid> VM.system_properties' or inspect Class.getMethod in a scratch program)
  2. Upgrade the JDK 8 to a recent HotSpot 8u release that implements getSystemCpuLoad
  3. Ignore the warning if JVM-level CPU metrics suffice; the agent intentionally falls back to UNSUPPORTED and continues running
  4. Ensure the agent is not running on an unsupported JVM vendor that Pinpoint does not list as supported for CPU metrics

Example fix

// before (agent behavior)
CpuUsageProvider systemCpuUsageProvider = new SystemCpuUsageProvider(operatingSystemMXBean);
try { systemCpuUsageProvider.getCpuUsage(); }
catch (NoSuchMethodError e) { systemCpuUsageProvider = CpuUsageProvider.UNSUPPORTED; }
// after (user-side guard: run on JDK8+ HotSpot that implements the method)
// java version "1.8.0_282" (recent HotSpot 8u) instead of e.g. openjdk "1.8.0_05"
Defensive patterns

Strategy: fallback

Validate before calling

// before enabling system CPU metrics on JDK8
Object os = ManagementFactory.getOperatingSystemMXBean();
boolean ok = os instanceof com.sun.management.OperatingSystemMXBean &&
    ((com.sun.management.OperatingSystemMXBean) os).getSystemCpuLoad() >= 0.0;

Type guard

boolean supportsSystemCpuLoad(java.lang.management.OperatingSystemMXBean os) {
  return os instanceof com.sun.management.OperatingSystemMXBean
      && ((com.sun.management.OperatingSystemMXBean) os).getSystemCpuLoad() >= 0.0;
}

Try / catch

try { usage = systemCpuUsageProvider.getCpuUsage(); }
catch (NoSuchMethodError e) { logger.warn("system cpu unsupported on this JVM", e); usage = -1; }

Prevention

When it happens

Trigger: Constructing DefaultCpuLoadMetric (via the CPU metric collector) on a JDK 8 JVM whose OperatingSystemMXBean implementation does not expose the system CPU usage method the provider binds to at runtime.

Common situations: Running the Pinpoint agent on JDK 8 with a non-HotSpot or old HotSpot build lacking com.sun.management.OperatingSystemMXBean.getSystemCpuLoad; containerized/minimal JRE distributions; reporting missing file.encoding/JMX implementations in some vendors' JDK 8 builds.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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