jmx通过客户端访问的问题

来源:互联网 发布:图片切片软件 编辑:程序博客网 时间:2024/05/05 12:13




I'm trying to implement JMX server side and client side.


I have the following xml in the server side:
Code:
<beans>
<bean id="registry"class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
<property name="port" value="8335" />
</bean>
<bean id="serverConnector"
class="org.springframework.jmx.support.ConnectorServerFactoryBean">
<property name="objectName" value="connector:name=rmi" />
<property name="serviceUrl"
value="service:jmx:rmi://localhost:8100/jndi/rmi://localhost:8335/server" />
</bean>
<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=testBean1" value-ref="testBean" />
</map>
</property>
<property name="server" ref="mbeanServer" />
</bean>
<bean id="testBean" class="com.jacada.jmx.JacadaJmxImpl">
</bean>
</beans>
And here's my client side:
Code:
<beans>
<bean id="clientConnector"
class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
<property name="serviceUrl"
value="service:jmx:rmi:///jndi/rmi://localhost:8335/server" />
</bean>
<bean id="proxy"class="org.springframework.jmx.access.MBeanProxyFactoryBean">
<property name="objectName" value="bean:name=testBean1" />
<property name="proxyInterface"
value="com.jacada.jmx.JacadaJmx" />
<property name="server" ref="clientConnector" />
</bean>
</beans>
The server side looks OK
But there's an exception on the client side:
Code:
Dec 5, 2006 6:22:17 PM org.springframework.core.CollectionFactory <clinit>
INFO: JDK 1.4+ collections available
Dec 5, 2006 6:22:17 PM org.springframework.core.CollectionFactory <clinit>
INFO: Commons Collections 3.x available
Dec 5, 2006 6:22:17 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationContext-client.xml]
Dec 5, 2006 6:22:17 PM org.springframework.context.support.AbstractRefreshableApplicationContext refreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=5947506]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [clientConnector,proxy]; root of BeanFactory hierarchy
Dec 5, 2006 6:22:17 PM org.springframework.context.support.AbstractApplicationContext refresh
INFO: 2 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=5947506]
Dec 5, 2006 6:22:17 PM org.springframework.context.support.AbstractApplicationContext initMessageSource
INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@1e0be38]
Dec 5, 2006 6:22:17 PM org.springframework.context.support.AbstractApplicationContext initApplicationEventMulticaster
INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@7a84e4]
Dec 5, 2006 6:22:17 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [clientConnector,proxy]; root of BeanFactory hierarchy]
Dec 5, 2006 6:22:17 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [clientConnector,proxy]; root of BeanFactory hierarchy}
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'proxy' defined in class path resource [applicationContext-client.xml]: Invocation of init method failed; nested exception is org.springframework.jmx.access.MBeanInfoRetrievalException: Unable to obtain MBean info for bean [bean:name=testBean1]: it is likely that this bean was unregistered during the proxy creation process; nested exception is javax.management.InstanceNotFoundException: bean:name=testBean1
Caused by: org.springframework.jmx.access.MBeanInfoRetrievalException: Unable to obtain MBean info for bean [bean:name=testBean1]: it is likely that this bean was unregistered during the proxy creation process; nested exception is javax.management.InstanceNotFoundException: bean:name=testBean1
Caused by: javax.management.InstanceNotFoundException: bean:name=testBean1
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBeanInfo(DefaultMBeanServerInterceptor.java:1303)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getMBeanInfo(JmxMBeanServer.java:903)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1402)
at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1341)
at javax.management.remote.rmi.RMIConnectionImpl.getMBeanInfo(RMIConnectionImpl.java:858)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl_Stub.getMBeanInfo(Unknown Source)
at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getMBeanInfo(RMIConnector.java:1031)
at org.springframework.jmx.access.MBeanClientInterceptor.retrieveMBeanInfo(MBeanClientInterceptor.java:226)
at org.springframework.jmx.access.MBeanClientInterceptor.afterPropertiesSet(MBeanClientInterceptor.java:190)
at org.springframework.jmx.access.MBeanProxyFactoryBean.afterPropertiesSet(MBeanProxyFactoryBean.java:72)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1057)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1024)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:140)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)

at org.springframework.context.support.ClassPathXmlAppli


今天遇到个问题,就是用jetty启动,去获取jmx发布出来的监控信息没有异常,当时换成tomcat就老是报错, 最终发现将mbeanServer的bean相关配置去掉就行, 据说好像是在运行时环境存在两个MBeanServers,而客户端所查询的指向了错误的一个。

0 0
原创粉丝点击