{"record":{"id":"c73992329a201274","repo":"pinpoint-apm/pinpoint","slug":"operatingsystemmxbean-not-available-c73992","errorCode":null,"errorMessage":"OperatingSystemMXBean not available","messagePattern":"OperatingSystemMXBean not available","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler-optional/profiler-optional-jdk8/src/main/java/com/navercorp/pinpoint/profiler/monitor/metric/cpu/oracle/DefaultCpuLoadMetric.java","lineNumber":41,"sourceCode":"import org.apache.logging.log4j.LogManager;\nimport org.apache.logging.log4j.Logger;\n\nimport java.lang.management.ManagementFactory;\n\n/**\n * @author HyunGil Jeong\n */\npublic class DefaultCpuLoadMetric implements CpuLoadMetric {\n\n    private final Logger logger = LogManager.getLogger(this.getClass());\n\n    private final CpuUsageProvider jvmCpuUsageProvider;\n    private final CpuUsageProvider systemCpuUsageProvider;\n\n    public DefaultCpuLoadMetric() {\n        final OperatingSystemMXBean operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();\n        if (operatingSystemMXBean == null) {\n            throw new IllegalStateException(\"OperatingSystemMXBean not available\");\n        }\n\n        CpuUsageProvider jvmCpuUsageProvider = new JvmCpuUsageProvider(operatingSystemMXBean);\n        try {\n            jvmCpuUsageProvider.getCpuUsage();\n        } catch (NoSuchMethodError e) {\n            logger.warn(\"Expected method not found for retrieving jvm cpu usage. Cause : {}\", e.getMessage());\n            jvmCpuUsageProvider = CpuUsageProvider.UNSUPPORTED;\n        }\n        this.jvmCpuUsageProvider = jvmCpuUsageProvider;\n\n        CpuUsageProvider systemCpuUsageProvider = new SystemCpuUsageProvider(operatingSystemMXBean);\n        try {\n            systemCpuUsageProvider.getCpuUsage();\n        } catch (NoSuchMethodError e) {\n            logger.warn(\"Expected method not found for retrieving system cpu usage. Cause : {}\", e.getMessage());\n            systemCpuUsageProvider = CpuUsageProvider.UNSUPPORTED;\n        }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler-optional/profiler-optional-jdk8/src/main/java/com/navercorp/pinpoint/profiler/monitor/metric/cpu/oracle/DefaultCpuLoadMetric.java#L23-L59","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Run on a HotSpot/Oracle/OpenJDK JVM that implements com.sun.management.OperatingSystemMXBean","Use the IBM or vendor-appropriate DefaultCpuLoadMetric module instead","Disable the Oracle CpuLoadMetric plugin on non-HotSpot JVMs","Check ManagementFactory.getOperatingSystemMXBean() class before enabling the plugin"],"exampleFix":"// before\nnew DefaultCpuLoadMetric(); // assumes HotSpot\n// after\nif (ManagementFactory.getOperatingSystemMXBean() instanceof com.sun.management.OperatingSystemMXBean) {\n    metric = new DefaultCpuLoadMetric();\n} else {\n    metric = new UnsupportedCpuLoadMetric();\n}","handlingStrategy":"validation","validationCode":"Object bean = ManagementFactory.getOperatingSystemMXBean();\nboolean hotspotOk = bean instanceof com.sun.management.OperatingSystemMXBean;","typeGuard":"boolean isHotSpotOperatingSystemMXBean(OperatingSystemMXBean b) {\n    return b instanceof com.sun.management.OperatingSystemMXBean;\n}","tryCatchPattern":null,"preventionTips":["Only load the Oracle CPU metric module on HotSpot-family JVMs","Guard with instanceof before construction","Document supported JVMs for your agent deployment"],"tags":["jmx","jvm","hotspot","cpu-metrics"],"backgroundTag":"unsupported-platform","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}