Java Mission Control (JMC) unable to change MBean attribute

179 Views Asked by At

I am unable to change attribute of the registered MBean in JMC (v 7.1), jdk1.8.0_172

enter image description here

However, I am able to change it in jconsole

enter image description here

MBean definitions and registration:

public class ProfilingController implements ProfilingControllerMBean {
    private boolean enabled = false;

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }
}

public interface ProfilingControllerMBean {
    void setEnabled(boolean enabled);
}


ManagementFactory.getPlatformMBeanServer().registerMBean(controller, new ObjectName("AppProfiling", "name", "ProfilingController"));
1

There are 1 best solutions below

2
On

I encountered the same problem. I use java 21, JDK Mission Control 8.3.1+b05 problem

I noticed the error message "Could not find attribute Enabled" and decided to add a get method to the interface and everything worked.

public interface ProfilingControllerMBean {
    void setEnabled(boolean enabled);

    boolean isEnabled();
}
public class ProfilingController implements ProfilingControllerMBean {
    private boolean enabled = true;

    @Override
    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }
}

Perhaps somewhere there is a description of the MBean convention and everything is described there.

decided I hope it will be useful to someone.