apache/cassandra · error · IllegalArgumentException

%s is not a valid JMX resource name

Error message

%s is not a valid JMX resource name

What it means

JMXResource.fromName parses a JMX permission resource name ('jmx' or 'jmx/<mbean>'). It throws IllegalArgumentException when the first segment is not the literal root 'jmx' or when the name has more than 2 segments, since MBean resources are exactly one level deep.

Source

Thrown at src/java/org/apache/cassandra/auth/JMXResource.java:79

    }

    public static JMXResource mbean(String name)
    {
        return new JMXResource(name);
    }

    /**
     * Parses a role resource name into a RoleResource instance.
     *
     * @param name Name of the data resource.
     * @return RoleResource instance matching the name.
     */
    public static JMXResource fromName(String name)
    {
        String[] parts = StringUtils.split(name, '/');

        if (!parts[0].equals(ROOT_NAME) || parts.length > 2)
            throw new IllegalArgumentException(String.format("%s is not a valid JMX resource name", name));

        if (parts.length == 1)
            return root();

        return mbean(parts[1]);
    }

    @Override
    public String getName()
    {
        if (level == Level.ROOT)
            return ROOT_NAME;
        else if (level == Level.MBEAN)
            return String.format("%s/%s", ROOT_NAME, name);
        throw new AssertionError();
    }

    /**

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Use names of the form 'jmx' or 'jmx/<mbean-object-name>' with no additional '/'-separated levels
  2. Encode the MBean ObjectName so it doesn't introduce extra '/' segments beyond the single resource level
  3. Use JMXResource.mbean(name) or JMXResource.root() directly instead of parsing arbitrary strings

Example fix

// before
JMXResource r = JMXResource.fromName("jmx/org/apache/type=Server");
// after
JMXResource r = JMXResource.fromName("jmx/org.apache.cassandra.db:type=StorageService");
Defensive patterns

Strategy: validation

Validate before calling

boolean isValidJmxResourceName(String name) {
    String[] parts = name.split("/");
    return parts.length >= 1 && parts.length <= 2 && "jmx".equals(parts[0]);
}

Try / catch

try { JMXResource r = JMXResource.fromName(name); } catch (IllegalArgumentException e) { log.error("bad jmx resource name: {}", name); }

Prevention

When it happens

Trigger: Calling JMXResource.fromName with 'jmx/a/b' (too deep), a wrong root like 'data/...' or 'jmxs/...', or an empty/malformed string.

Common situations: Deserializing permission entries where the resource kind prefix got mixed up; hand-writing MBean resource names with extra slash-delimited properties instead of the canonical ObjectName form; scripts iterating mixed resource lists and calling the wrong fromName.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/fde395755b5c5ee2. Report an issue: GitHub.