how to get register MBean with method getPlatformMXBean()?
<p>I have register mbean by using    </p>

<pre><code>ManagementFactory.getPlatformMBeanServer().registerMBean(mbean, name);
</code></pre>

<p>And I can see this mbean in jconsole. I want get it by <code>ManagementFactory.getPlatformMXBean(mbean)</code>, but it throws Exception </p>

<blockquote>
  <p>mbean not a platform management interface.</p>
</blockquote>

<p>How can I get this registered bean?</p>

<p>Below is the code.</p>

<pre><code>public void contextInitialized(ServletContextEvent servletContextEvent) {
    System.out.println("Registering MBean...");
    try {
        ObjectName name = new ObjectName("common.test:type=MbeanTestImplement");
        MbeanTestInterface mbean = new MbeanTestImplement();
        ManagementFactory.getPlatformMBeanServer().registerMBean(mbean, name);
        MbeanTestImplement mxbean = ManagementFactory.getPlatformMXBean(MbeanTestImplement.class);
        System.out.println(mxbean.getName());
    } catch (Exception e){
        e.printStackTrace();
    }
    //ManagementFactory.getMBeanserverConnection()
}
</code></pre>

<p>MbeanTestInterface extends PlatformManagedObject, and MbeanTestImplement implement MbeanTestInterface.</p>

<pre><code>public interface MbeanTestInterface extends PlatformManagedObject {
    public String getName();
}

public class MbeanTestImplement implements MbeanTestInterface {
    @Override
    public String getName() {
        return MbeanTestImplement.class.toString();
    }

    @Override
    public ObjectName getObjectName() {
        return null;
    }
}
</code></pre>