Announcement Announcement Module
No announcement yet.
Duplicate Spring jmx Mbean grief Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Duplicate Spring jmx Mbean grief

    Hope someone can help with this as I'm now stuck.

    We have a couple of Spring controllers that we wish to manage using jmx and I've run into a problem with injection/instantiation.

    this is the bean I wish to manage:

    <bean id="thumbnailController" class="com.something.controller.PDFThumbnailController" scope="singleton">
     		<property name="imageHeight" value="0"/>
     		<property name="imageWidth" value="200"/>
     		<property name="timeout" value="15"/>
     		<property name="viewName" value="empty/nothing"/> 
    Specifically the timeout property.
    Having looked through the docs I came up with this config for the jmx stuff:

    <bean id="mbeanServer" class="">
         <property name="locateExistingServerIfPossible" value="true"></property>
    <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
         <property name="beans">
                   <entry key="bean:name=previewImageDownload" value-ref="thumbnailController"/>
                   <entry key="bean:name=bigPreviewImageDownload" value-ref="bigThumbnailController"/>
        <property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/>
        <property name="assembler">
             <bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
                  <property name="interfaceMappings">
    	        	<prop key="previewImageDownload">
        	    	        <prop key="bigPreviewImageDownload">
        <property name="server" ref="mbeanServer"/>
    <bean id="jmxServices" class="">
         <property name="managerName" value="Catalina:type=Manager,path=/ep4,host=localhost"/>
         <property name="previewImageName" value="bean:name=previewImageDownload"/>
         <property name="bigPreviewImageName" value="bean:name=bigPreviewImageDownload"/>
         <property name="server" ref="mbeanServer"/>
    I can access and change the properties of the controller using JConsole and via the jmxServices just fine, however, the controller instance that has the changed values is NOT the one that gets used by Spring to handle requests.

    I have debugged this and there are two instances of the thumbnailController bean; the one that is defined as a controller and another one that get created by the exporter (I think). Having read the docs it implies that beans created in exporter will be proxies to Spring beans but in my case they are totally different instances (albeit with the same initial field values of the other thumbnailController).

    Has anyone else come across this? or I may have totally misunderstood the documentation (which is a wee bit thin btw).

    Many Thanks