Results 1 to 2 of 2

Thread: JMX MBeans exported via Spring - how to also see platform MBeans?

Hybrid View

  1. #1

    Default JMX MBeans exported via Spring (JSR 160) - how to also see platform MBeans?

    Using spring 2.5.6.SEC01 with JDK 1.6.0_20. We use Spring to expose some beans using @ManagedResource. The configuration looks as follows:
    Code:
        <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/>
        <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
            <property name="port" value="${rmi.registry.port}"/>
        </bean>
    
        <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
            <property name="assembler">
                <bean class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
                    <property name="attributeSource" ref="jmxAttributeSource"/>
                </bean>
            </property>
            <property name="namingStrategy">
                <bean class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
                    <property name="attributeSource" ref="jmxAttributeSource"/>
                </bean>
            </property>
            <property name="autodetect" value="true"/>
            <property name="server" ref="mbeanServer"/>
        </bean>
    
        <bean id="jmxAttributeSource"
              class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/>
    
        <bean id="serverConnector" class="ca.utoronto.sis.util.ResourceAwareConnectorServerFactoryBean">
            <property name="server" ref="mbeanServer"/>
            <property name="objectName" value="connector:name=rmi"/>
            <property name="serviceUrl"
                      value="service:jmx:rmi://localhost:${jmx.connector.port}/jndi/rmi://localhost:${rmi.registry.port}/swsjmx"/>
            <property name="environment">
                <map>
                    <!-- the following is only valid when the sun jmx implementation is used -->
                    <entry key="jmx.remote.x.password.file" value="jmxusers.properties"/>
                </map>
            </property>
        </bean>
    Everything works as expected and we can see our custom MBeans using MC4J. Is it possible to connect to the same mbean server and also see the platform MBeans (e.g., MemoryPoolMXBean)? MBeanProxyFactoryBean perhaps? Any pointers are appreciated.

    thanks in advance,
    --
    Haroon
    Last edited by haroon.rafique; Jun 14th, 2010 at 03:25 PM.

  2. #2

    Default

    Quote Originally Posted by haroon.rafique View Post
    Everything works as expected and we can see our custom MBeans using MC4J. Is it possible to connect to the same mbean server and also see the platform MBeans (e.g., MemoryPoolMXBean)? MBeanProxyFactoryBean perhaps? Any pointers are appreciated.
    The following seems to have worked, if anyone else needs this to work. I changed my mbeanServer to say:
    Code:
    <bean id="mbeanServer" class="java.lang.management.ManagementFactory"
       factory-method="getPlatformMBeanServer"/>
    and I changed my serviceUrl to say:
    Code:
    <property name="serviceUrl"
       value="service:jmx:rmi://localhost/jndi/rmi://localhost:${rmi.registry.port}/swsjmx"/>
    and now I can see my MBeans in the ca.utoronto.sis package as well as the platform MBeans in java.lang package (using, e.g., MC4J).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •