Announcement Announcement Module
Collapse
No announcement yet.
JMX Server/Client implementation problems Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMX Server/Client implementation problems

    Hello,
    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 [[email protected]38]
    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.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:68)
    	at com.jacada.jmx.MainClient.main(MainClient.java:9)
    What is wrong?
    Thank you in advance.
    Victor.

  • #2
    I haven't worked with JMX and RMI in a long time but it seems that your server publishes the bean under:
    service:jmx:rmi://localhost:8100/jndi/rmi://localhost:8335/server
    while your client looks for the bean under:
    service:jmx:rmi:///jndi/rmi://localhost:8335/server

    Comment


    • #3
      JMX Server/Client implementation problems

      Than you.

      I've tried to change the url in the client so it will be the same as in the server, but I've got the same exception.

      Victor.

      Comment


      • #4
        You could use jconsole to connect to the server using the client connector and browse the existing MBeans. You might be running into a lazy loading issue - you bean is not exposed since it wasn't used yet and thus it hasn't been instantiated yet.

        Comment


        • #5
          JMX Server/Client implementation problems

          I've added lazy-init="false" to my beans - same result.
          I've connected with jconsole and I can not see the MBean (I see only the connector/rmi MBean which is the serverConnector).

          my new server applicationContext.xml:

          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"  lazy-init="false"/>
          	
          	<bean id="exporter"
          		class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
          
          		<property name="beans">
          			<map>
          				<entry key="connector:name=testBean1" value-ref="testBean" />
          			</map>
          		</property>
          		<property name="server" ref="mbeanServer" />
          	</bean>
          	
          	<bean id="testBean" class="com.jacada.jmx.JacadaJmxImpl" lazy-init="false">
          	</bean>
          </beans>

          Comment


          • #6
            Have you checked your firewall settings on the client and server? In the extreme case it could be that the registry is not even being created (did you say you could see the connector in jconsole?). If you can, just disable firewalls on both machines until you can work out what is happening.

            Comment


            • #7
              Thank you David,

              both client and server are running on the same machine, and both of them are configured with "localhost" as hostname.
              So it probably something else.

              Victor.

              Comment


              • #8
                As far as I know "localhost" is not immune from firewalls. I have a firewall on my PC, and it has to be explicitly either disabled or tweaked to allow me to create an rmi registry. Just check if you have any firewall running and disable it if you find one while you test your server-client.

                Comment


                • #9
                  The solution.

                  Hello all,

                  I know what was the problem and I think that I have a solution.

                  The problem was that in the runtime there were 2 MBeanServers, and the client query was ponting to the wrong one.

                  To solve it I've removed "mbeanServer" bean from the server context.
                  The server context xml:
                  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="exporter"
                  		class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
                  
                  		<property name="beans">
                  			<map>
                  				<entry key="connector:name=testBean1" value-ref="testBean" />
                  			</map>
                  		</property>
                  	</bean>
                  	
                  	<bean id="testBean" class="com.jacada.jmx.JacadaJmxImpl" lazy-init="false">
                  	</bean>
                  </beans>
                  Victor.

                  Comment


                  • #10
                    Maybe even better solution

                    I think removing the MBeanServer creation won't work, if the app is run with JRE 1.4.2 and/or JRE 5.

                    We're using the following setup:

                    Code:
                    	<bean id="mbeanServer" 
                    	 	class="org.springframework.jmx.support.MBeanServerFactoryBean"
                    	 	depends-on="jmx_registry">
                    	
                    		<property name="locateExistingServerIfPossible" value="true"/>
                    		<property name="defaultDomain" value="${verst.jmx.domain}"/>
                    	
                    	</bean>
                    Kind regards
                    Juergen

                    Comment

                    Working...
                    X