"WFLYJMX0012: params and description have different lengths" when stopping Wildfly programmatically

Viewed 237

In my code I used to stop the Wildfly (16.0.0.Final) programmatically like this:

[...]
Thread shutdownThread = new Thread(){
    @Override
    public void run() {
        try {
            MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
            try {
                logger.info("Stopping server...");
                ObjectName objectName = new ObjectName("jboss.as:management-root=server");
                mBeanServer.invoke(objectName, "shutdown", new Object[] { false, 60 }, new String[] { boolean.class.getName(), int.class.getName() });
            } catch ( InstanceNotFoundException | ReflectionException | MBeanException | MalformedObjectNameException e ) {
                logger.error("Failed to stop server, error msg is: " + e);
            }
        } catch ( Exception e ) {
            logger.error(e.getMessage(), e);
        }
    }
};
[...]

Curiously this stopped working. I get the following error message:

WFLYJMX0012: params and description have different lengths: java.lang.IllegalArgumentException: 

Any idea on that? Thanks a lot, Kai

2 Answers

In wildfly 16, they added a third parameter for graceful shutdown.

 mBeanServer.invoke(objectName, "shutdown", new Object[] { false, 60, 60 }, new String[] { boolean.class.getName(), int.class.getName(), int.class.getName() });

While the third parameter is listed as optional, we had the same error until we added it.

https://wildscribe.github.io/WildFly/17.0/index.html for more information.

The error indicates that the actual arguments provided for the JMX operation does not match the signature of the operation itself.

In general, it can be motivated because you switched from a standalone to a domain configuration.

At least, you will find a similar problem if you use the CLI: in this case, you need to indicate the host name to shutdown as the first argument of the invocation, the rest of the arguments, whether restart again and the different timeouts, remains the same.

But in this concrete case, perhaps, it is not clear for me reading your question, you switched to Wildly version 16.0.0.Final from a previous one.

As you can see in the WildFly 16.0 Model Reference or if you inspect, with JConsole or some other similar tool, the mbeans exposed by the JMX tree, the shutdown operation signature is the following:

jmx capture

As we also mention, although the three arguments are not required, the mbean signature defines them, and all the arguments should be provided.

Related