apache/hadoop · warning · IllegalArgumentException
${objectName} is not a valid Hadoop mbean
Error message
${objectName} is not a valid Hadoop mbean What it means
IllegalArgumentException from MBeans.getMbeanNameService(ObjectName) when the given JMX ObjectName does not match Hadoop's MBean naming pattern '^Hadoop:service=<SERVICE>,name=<NAME>' (MBEAN_NAME_PATTERN). Hadoop registers all its MBeans under the 'Hadoop:' domain with exactly a 'service=' key and a 'name=' key; these helper methods decompose such names and reject anything else. The message prints the offending ObjectName so the mismatch is obvious.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/MBeans.java:121
if (LOG.isTraceEnabled()) {
LOG.trace("Failed to register MBean \"" + name + "\"", iaee);
} else {
LOG.warn("Failed to register MBean \"" + name
+ "\": Instance already exists.");
}
} catch (Exception e) {
LOG.warn("Failed to register MBean \"" + name + "\"", e);
}
}
return null;
}
public static String getMbeanNameService(final ObjectName objectName) {
Matcher matcher = MBEAN_NAME_PATTERN.matcher(objectName.toString());
if (matcher.matches()) {
return matcher.group(1);
} else {
throw new IllegalArgumentException(
objectName + " is not a valid Hadoop mbean");
}
}
public static String getMbeanNameName(final ObjectName objectName) {
Matcher matcher = MBEAN_NAME_PATTERN.matcher(objectName.toString());
if (matcher.matches()) {
return matcher.group(2);
} else {
throw new IllegalArgumentException(
objectName + " is not a valid Hadoop mbean");
}
}
static public void unregister(ObjectName mbeanName) {
LOG.debug("Unregistering "+ mbeanName);
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
if (mbeanName == null) {View on GitHub (pinned to 2add963021)
Solutions
- Only call getMbeanNameService/getMbeanNameName on ObjectNames you obtained via MBeans.register() or that you have verified start with 'Hadoop:service=...,name=...'
- Pre-filter ObjectNames with your own regex or startsWith("Hadoop:service=") check before calling the helper
- If you register custom beans, use the standard form new ObjectName("Hadoop:service=<svc>,name=<name>") so decomposition works
Example fix
// before
String svc = MBeans.getMbeanNameService(objectName); // objectName = 'java.lang:type=Memory' -> IllegalArgumentException
// after
if (objectName.getDomain().equals("Hadoop")
&& objectName.getKeyPropertyList().size() == 2
&& objectName.getKeyProperty("service") != null
&& objectName.getKeyProperty("name") != null) {
String svc = MBeans.getMbeanNameService(objectName);
} Defensive patterns
Strategy: validation
Validate before calling
private static final Pattern HADOOP_MBEAN =
Pattern.compile("^Hadoop:service=([^,]+),name=(.+)$");
boolean isHadoopMbean(ObjectName n) { return HADOOP_MBEAN.matcher(n.toString()).matches(); } Type guard
static boolean isHadoopMbeanName(ObjectName n) {
return "Hadoop".equals(n.getDomain())
&& n.getKeyProperty("service") != null
&& n.getKeyProperty("name") != null
&& n.getKeyPropertyList().size() == 2;
} Prevention
- When iterating the platform MBeanServer, filter names with the pattern before calling these helpers
- Register custom beans via MBeans.register so names always match the convention
- Unit-test name helpers against representative ObjectNames
When it happens
Trigger: Calling getMbeanNameService() with an ObjectName from a non-Hadoop bean (e.g., 'java.lang:type=Memory'), or a Hadoop bean whose name was created with extra keys, missing keys, or a different domain (e.g., 'Hadoop:service=NameNode,name=NameNodeInfo,extra=1').
Common situations: Monitoring/tooling code that iterates all platform MBeans and blindly passes each name to these helpers; refactoring that renames MBeans away from the standard pattern; third-party code registering beans into the Hadoop domain with nonstandard keys.
Related errors
- Wrong length: {digest.length}
- Wrong length: {hex.length}
- Not a hex character: {c}
- No schema options are provided
- No codec option is provided
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/4f6f944efe875066.
Report an issue: GitHub.