java - 找不到 MBean "jboss.web:type=Manager,path=/,host=localhost"

标签 java jboss jmx mbeans

我正在尝试访问注册为的 JBoss v4.2 MBean

jboss.web:type=Manager,path=/,host=localhost

使用以下代码:

ObjectName name = new ObjectName("jboss.web:type=Manager,path=/,host=localhost");
ManagementFactory.getPlatformMBeanServer().getAttribute(name, "activeSessions");

但是这段代码不断抛出以下异常:

javax.management.InstanceNotFoundException : jboss.web:type=Manager,path=/,host=localhost is not registered.

另一方面,我可以通过 ...//localhost:8080/jmx-console/使用 jmx-console 查看和使用此 bean - MBean 可用。

Screenshot

通过代码访问同一个 MBean 还需要什么?

最佳答案

找到了...

ObjectName name = new ObjectName("jboss.web:type=Manager,path=/,host=localhost");
this.sessions = new Long((Integer) MBeanServerLocator.locateJBoss().getAttribute(name, "activeSessions"));

我必须找到正确的 MBeanServer...MBeanServerLocator.locateJBoss() 解决了这个问题。

关于java - 找不到 MBean "jboss.web:type=Manager,path=/,host=localhost",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15632000/

相关文章:

javax.命名.NameNotFoundException

java - WebSphere AdminClient 连接到本地托管进程而不是 HOST :PORT specified in properties

java - JMX:访问运行 JVM 的文件系统的标准能力

JMX_exporter 在 Prometheus 和 Grafana 中显示错误

java - 扫描图像到可读文本

java - Jsf RichFaces 自动完成 : get the InputValue for autocomplete- method()

java - HikariCP - 使用 HikariDataSource 的链接错误

jboss - Jboss 中创建了多少个消息驱动 Bean?

java - Spring 异步: How to call spring hateoas ControllerLinkBuilder inside Async method

java - 在这些调用之间使用系统输出打印的双重递归调用 Ap 计算机科学