【问题标题】:NameNotFound on remote jmx call with rmiNameNotFound 远程 jmx 调用与 rmi
【发布时间】:2014-07-29 07:36:24
【问题描述】:

我正在尝试使用 guide 远程调用 spring 暴露的 jmx bean

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

原因:java.io.IOException:无法检索 RMIServer 存根: javax.naming.NameNotFoundException:jmxrmi 在 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>

有什么想法吗?

【问题讨论】:

    标签: java spring jmx spring-jmx


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-05
      • 2015-07-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-24
      • 1970-01-01
      • 2011-07-03
      相关资源
      最近更新 更多