用rmi远程jmx调用NameNotFound

时间:2014-07-29 07:36:25

标签: java spring jmx spring-jmx

我正试图使用​​此guide

远程调用jmx bean暴露的bean

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

  

引起:java.io.IOException:无法检索RMIServer存根:   javax.naming.NameNotFoundException:jmxrmi at   javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:357)     在   javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:267)     在   org.springframework.jmx.support.MBeanServerConnectionFactoryBean.connect(MBeanServerConnectionFactoryBean.java:126)     在   org.springframework.jmx.support.MBeanServerConnectionFactoryBean.afterPropertiesSet(MBeanServerConnectionFactoryBean.java:114)     在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)     在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)     ... 38更多引起:javax.naming.NameNotFoundException:jmxrmi

这是我的服务器弹簧上下文

<?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>

这是我的客户弹簧背景

<?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>

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

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

相关问题