Announcement Announcement Module
Collapse
No announcement yet.
MBean not showing up in jconsole Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MBean not showing up in jconsole

    Hi,
    I'm trying to register a spring bean as a JMX bean via jconsole but can't get it working. I'm starting the spring app with the following jmx related options:

    -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1234 -Dcom.sun.management.jmxremote.password.file=/home/dendenners/jmxremote.password

    I've the following jmx config in my application context:
    <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServer FactoryBean"/>
    <bean id="exporter"
    class="org.springframework.jmx.export.MBeanExporte r">
    <property name="beans">
    <map>
    <entry key="bean:name=ipSocket1">
    <ref local="ipSocket1"/>
    </entry>
    </map>
    </property>
    <property name="server" ref="mbeanServer" />
    </bean>

    Now I can connect to the running java application using jconsole, but the ipSocket1 bean is not showing up as a jmx manageable bean in the console (I just get what look like default attributes under JMImplementation, java.lang and java.util.logging. I suspect I may need extra entries under the 'beans' attribute in the MBeanExporter, but I don't know what I should have in here to allow me to manage the ipSocket1 instance under jconsole. Any help would be greatly appreciated.
    Denis

  • #2
    You are starting two mbean servers - one with the jdk (through the command line params) and the other inside through Spring and the mbeanServer declaration.
    Either stop using the mbean server started with the jdk or remove the mbeanserver bean and let the exporter autodetect the mbean server (in your case the one started by the jdk).

    Comment


    • #3
      Hi Costin, thanks for the post. I've tried removing the mbeanserver definition in my app context, so that all I have left by way of JMX config in my app context is simply

      <bean id="exporter"
      class="org.springframework.jmx.export.MBeanExporte r">
      <property name="beans">
      <map>
      <entry key="bean:name=ipSocket1">
      <ref local="ipSocket1"/>
      </entry>
      </map>
      </property>
      </bean>
      I haven't changed the startup options I was using.
      However, jconsole still just shows the default beans, no sign of ipSocket1. Any idea of what I might be doing wrong?
      Thanks
      Denis

      Comment


      • #4
        In Spring beans by default are lazy loaded - make sure the exporter is not lazy loaded so that the exporting of the mbean is done at startup.

        Comment


        • #5
          Hi,
          I've also noticed that when I register the mbean directly with the mbean server like this:

          ArrayList servers = MBeanServerFactory.findMBeanServer(null);
          MBeanServer server = (MBeanServer) servers.get(0);
          server.registerMBean(factory.getBean("ipSocket1"), new ObjectName("bean:name=ipSocket1"));

          The bean shows up in jconsole. The size of the servers ArrayList is 1, so it looks as if there is only one MBeanServer running. There must be something silly I'm missing.
          Denis

          Comment


          • #6
            Thanks again Costin - I hadn't seen your post before posting my last reply. I explicitly called the exporter using
            MBeanExporter exporter = (MBeanExporter) factory.getBean("exporter");
            just after instantiating the application context, it works! Thanks a lot, this is fine, but I'm wondering is there a more elegant way to get the same behaviour without explicitly creating the MBeanExporter instance in my startup class?
            Thanks a lot for your help
            Denis

            Comment


            • #7
              yes - set lazy-init="false" on your exporter definition inside your application context (there are more details in the reference documentation).

              Comment


              • #8
                That's what I thought it should be. However, when I set lazy-init="false" on the MBeanExporter, the mbeans I define within it don't seem to get picked up in jconsole. I can do the getBean() thing, so it's not a big deal. It's not what I was expecting though.
                Denis

                Comment


                • #9
                  Can you post Spring start-up logging and your appContext again?

                  Comment


                  • #10
                    Here's the app context config:

                    <bean id="ipSocket1"
                    class="com.fexcodcc.fdac.management.GenericServerS ocket" >
                    <property name="handlerSelector">
                    <ref bean="noEnqHandlerSelector"/>
                    </property>
                    <property name="dataReader">
                    <ref bean="timeoutReader"/>
                    </property>
                    <property name="pushbackBufferSize"><value>500</value></property>
                    <property name="dataWriter">
                    <ref bean="printStreamWriter"/>
                    </property>
                    <property name="numberOfThreads"><value>1</value></property>
                    <property name="port"><value>7900</value></property>
                    <property name="socketTimeout"><value>3000</value></property>
                    </bean>

                    and here's the mbean exporter:

                    <bean id="exporter"
                    class="org.springframework.jmx.export.MBeanExporte r" lazy-init="false">
                    <property name="beans">
                    <map>
                    <entry key="bean:name=ipSocket1" value-ref="ipSocket1"/>
                    </map>
                    </property>
                    <property name="autodetect" value="true"/>
                    </bean>


                    I can't find any references to the "exporter" bean in the startup debug logging of the application! Everything else is there, for example for the ipSocket1:

                    2006-01-07 12:02:40,200 DEBUG [main] xml.XmlBeanFactory Creating shared instance of singleton bean 'ipSocket1'
                    2006-01-07 12:02:40,200 DEBUG [main] xml.XmlBeanFactory Creating instance of bean 'ipSocket1' with merged definition [Root bean: class [com.fexcodcc.fdac.management.GenericServerSocket]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; initMethodName=null; destroyMethodName=null; factoryMethodName=null; factoryBeanName=null; defined in file [/usr/local/fdac/cfg/ApplicationContext.xml]]
                    2006-01-07 12:02:40,201 DEBUG [main] xml.XmlBeanFactory Invoking BeanPostProcessors before instantiation of bean 'ipSocket1'

                    Comment


                    • #11
                      hmm... can you see the exporter after ipSocket1 is used and initialized?

                      Comment

                      Working...
                      X