Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: MBean not showing up in jconsole

  1. #1
    Join Date
    Nov 2004
    Location
    Rural Ireland
    Posts
    36

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Nov 2004
    Location
    Rural Ireland
    Posts
    36

    Default

    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

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5
    Join Date
    Nov 2004
    Location
    Rural Ireland
    Posts
    36

    Default

    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

  6. #6
    Join Date
    Nov 2004
    Location
    Rural Ireland
    Posts
    36

    Default

    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

  7. #7
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    yes - set lazy-init="false" on your exporter definition inside your application context (there are more details in the reference documentation).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  8. #8
    Join Date
    Nov 2004
    Location
    Rural Ireland
    Posts
    36

    Default

    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

  9. #9
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Can you post Spring start-up logging and your appContext again?
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  10. #10
    Join Date
    Nov 2004
    Location
    Rural Ireland
    Posts
    36

    Default

    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'

Posting Permissions

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