gpt4 book ai didi

java - 使用 rmi 进行远程 jmx 调用时的 NameNotFound

转载 作者:行者123 更新时间:2023-12-01 12:42:03 25 4
gpt4 key购买 nike

我正在尝试使用此 guide 远程调用 spring 公开的 jmx bean

但是当我启动客户端代码时,它无法加载应用程序上下文并出现此类错误

Caused by: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: jmxrmi at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:357) at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:267) at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.connect(MBeanServerConnectionFactoryBean.java:126) at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.afterPropertiesSet(MBeanServerConnectionFactoryBean.java:114) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ... 38 more Caused by: javax.naming.NameNotFoundException: jmxrmi

这是我的服务器 spring 上下文

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sws="http://www.springframework.org/schema/web-services"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean" />

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="bean:name=testBean" value-ref="testBean" />
</map>
</property>
<property name="assembler">
<bean
class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
<property name="managedInterfaces">
<value>jmx.IJmxTestBean</value>
</property>
</bean>
</property>
<property name="server" ref="mbeanServer" />
</bean>

<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
<property name="port" value="1199" />
</bean>

<bean id="testBean" class="jmx.JmxTestBean">
<property name="name" value="TEST" />
<property name="age" value="100" />
</bean>

<bean id="serverConnector"
class="org.springframework.jmx.support.ConnectorServerFactoryBean" depends-on="registry">
<property name="objectName" value="connector:name=rmi" />
<property name="serviceUrl"
value="service:jmx:rmi://localhost/jndi/rmi://localhost:1199/jmxrmi" />
</bean>

这是我的客户端 spring 上下文

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sws="http://www.springframework.org/schema/web-services"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<bean id="clientConnector"
class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
<property name="serviceUrl"
value="service:jmx:rmi://localhost/jndi/rmi://localhost:1199/jmxrmi" />
</bean>

<bean id="proxy" class="org.springframework.jmx.access.MBeanProxyFactoryBean">
<property name="objectName" value="bean:name=testBean" />
<property name="proxyInterface" value="jmx.IJmxTestBean" />
<property name="server" ref="clientConnector" />
</bean>

有什么想法吗?

最佳答案

好吧,这不是 spring jmx 的问题,而是我正在部署应用程序的 jboss eap 的问题。当我作为独立客户端或在 jetty 上启动 spring 上下文时,此代码运行得非常好。由于我在 JBoss EAP 6.2 上运行此程序,因此不支持 rmi 的 jmx,我需要找到另一种方法。

关于java - 使用 rmi 进行远程 jmx 调用时的 NameNotFound,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25010315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com