java - MBean 未出现在 JConsole 中

标签 java glassfish jmx

我正在 Netbeans 中开发一个 java Web 应用程序。现在我想使用 jconsole 监控我的应用程序。

 public static void main(String[] args) throws Exception {
        String name="Example";

        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

        ObjectName object = new ObjectName("org.javalobby.tnt.jmx:type=example");
        mbs.registerMBean(name, object);
    }

我还将以下行添加到 glassfish:

-Djava.rmi.server.hostname=myhost

-Dcom.sun.management.jmxremote.port=8686

-Dcom.sun.management.jmxremote.ssl=false

-Dcom.sun.management.jmxremote.authenticate=false

问题是我的 bean 没有出现在 JConsole 上。我做错了什么?

最佳答案

您正在将字符串对象作为 MBean 对象传递。关注documentation如下。 使用这个blog link创建示例测试 mbean。

"An MBean is a managed Java object, similar to a JavaBeanTM, that follows the design patterns set forth in the instrumentation level of the JMX specification. An MBean can represent a device, an application, or any resource that needs to be managed. MBeans expose a management interface: a set of readable and/or writable attributes and a set of invokable operations, along with a self-description.

A standard MBean is defined by writing a Java interface called SomethingMBean and a Java class called Something that implements that interface. Every method in the interface defines either an attribute or an operation in the MBean. By default every method defines an operation. Attributes and operations are simply methods which follow certain design patterns. A standard MBean is composed of the MBean interface which lists the methods for all exposed attributes and operations, and the class which implements this interface and provides the functionality of the instrumented resource."

关于java - MBean 未出现在 JConsole 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27620894/

相关文章:

java - 使用@secured方法时为"An Authentication object was not found in the SecurityContext"

java - MySQL DB JavaEE Glassfish 中的问号

java - 安装 JBoss 服务器后,我无法访问 jmx 控制台

java - 访问 EJB 分离的接口(interface)时出现 IllegalAccessException

jakarta-ee - jmx 无法连接到本地主机

java - 附加到远程(非本地)VM

java - Spring Webapplistener 问题

java - Eclipse Google -App -Engine "Will NOT Enhance"

java.lang.NoSuchMethodError : No interface method onTransitionToIdle()V 错误

java - 我如何在 JSP 中创建一个程序来生成您可以回答的随机加法方程,然后检查您是否正确?