gpt4 book ai didi

java - Spring MBean客户端认为MBean服务是RMI连接

转载 作者:太空宇宙 更新时间:2023-11-04 07:09:17 24 4
gpt4 key购买 nike

我在将自己的 Spring MBean 客户端连接到“Hello World!”时遇到问题。服务如JMX examples from Oracle中所示。该服务和包含的客户端工作正常。

我认为这与 RMI 连接在期待其他内容时返回有关...但我不知道解决方案是什么,或者即使这是一个正确的推论。

或者我是否以某种方式使用了“错误的”MBeanServerConnectionFactoryBean?

有什么想法吗?

这是我对该 bean 的 spring 配置:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

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

<bean id="jmxClient"
class="com.foo.jmx.MBeanPollingClient">
<property name="mbeanServerConnection"
ref="mBeanServerClient" />
</bean>
</beans>

这是我的实现代码:

import org.springframework.jmx.support.MBeanServerConnectionFactoryBean;

public class MBeanPollingClient {

private MBeanServerConnectionFactoryBean mbeanServerConnection = null;

public void setMbeanServerConnection ( MBeanServerConnectionFactoryBean m )
{
mbeanServerConnection = m;
}

public MBeanServerConnectionFactoryBean getMbeanServerConnection ( )
{
return mbeanServerConnection;
}

}

我收到的错误:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmxClient' defined in class path resource [jmx-beans.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection' to required type 'org.springframework.jmx.support.MBeanServerConnectionFactoryBean' for property 'mbeanServerConnection'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection] to required type [org.springframework.jmx.support.MBeanServerConnectionFactoryBean] for property 'mbeanServerConnection': no matching editors or conversion strategy found

最佳答案

Spring会给你一个由工厂提供的MBeanServerConnection。要修复错误,只需更改

private MBeanServerConnectionFactoryBean mbeanServerConnection;

private MBeanServerConnection mbeanServerConnection;

关于java - Spring MBean客户端认为MBean服务是RMI连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20894897/

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