apache/cassandra · error · java.lang.IllegalArgumentException
Null MBeanServer
Error message
Null MBeanServer
What it means
When setMBeanServer passes the no-subject check, the proxy validates its single argument. A null first argument produces IllegalArgumentException("Null MBeanServer") at line 184. The proxy refuses to install a null server because every subsequent operation (authorize, invoke, queryNames) would dereference it and fail with NPEs.
Source
Thrown at src/java/org/apache/cassandra/auth/jmx/AuthorizationProxy.java:184
Subject subject = Subject.getSubject(acc);
try
{
if ("getMBeanServer".equals(methodName))
throw new SecurityException("Access denied");
// Corresponds to MBeanServer.invoke
if (methodName.equals("invoke") && args.length == 4)
checkVulnerableMethods(args);
// Allow setMBeanServer iff performed on behalf of the connector server itself
if (("setMBeanServer").equals(methodName))
{
if (subject != null)
throw new SecurityException("Access denied");
if (args[0] == null)
throw new IllegalArgumentException("Null MBeanServer");
if (mbs != null)
throw new IllegalArgumentException("MBeanServer already initialized");
mbs = (MBeanServer) args[0];
return null;
}
if (authorize(subject, methodName, args))
{
Object invoke = invoke(method, args);
listener.onInvocation(subject, method, args);
return invoke;
}
throw new SecurityException("Access Denied");
}
catch (Exception e)View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pass a non-null MBeanServer — typically ManagementFactory.getPlatformMBeanServer() — to setMBeanServer.
- Check where the MBeanServer variable comes from; ensure the platform server is obtained before the JMX connector server is constructed.
- In tests, assert the server instance is created before invoking the proxy.
Example fix
// before proxyMBeanServer.setMBeanServer(null); // after MBeanServer server = ManagementFactory.getPlatformMBeanServer(); proxyMBeanServer.setMBeanServer(server);
Defensive patterns
Strategy: validation
Validate before calling
MBeanServer server = ManagementFactory.getPlatformMBeanServer(); Objects.requireNonNull(server, "Platform MBeanServer must exist before JMX connector bootstrap"); proxyMBeanServer.setMBeanServer(server);
Prevention
- Always pass ManagementFactory.getPlatformMBeanServer() (or an explicitly constructed server) to setMBeanServer.
- Null-check the server argument at the bootstrap call site before wiring the connector.
When it happens
Trigger: setMBeanServer called (with subject == null, e.g. during connector bootstrap or a test) passing args = new Object[]{null} — i.e. no MBeanServer instance supplied.
Common situations: Miswired JMX environment/bootstrap code constructing the connector without a platform MBeanServer; unit tests invoking the proxy's setMBeanServer with an unset local variable; reflection-based setup that silently dropped the server argument.
Related errors
- must provide eventLoop
- throw new IOException(e)
- %s is not a valid JMX resource name
- JAAS login configuration missing for JMX authenticator setup
- Authentication error
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/7af5d412562d84cf.
Report an issue: GitHub.