Announcement Announcement Module
Collapse
No announcement yet.
Duplicate Spring jmx Mbean grief Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:

    Code:
    <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"/> 
     </bean>
    Specifically the timeout property.
    Having looked through the docs I came up with this config for the jmx stuff:

    Code:
    <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
         <property name="locateExistingServerIfPossible" value="true"></property>
    </bean> 
    
    <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
         <property name="beans">
              <map>
                   <entry key="bean:name=previewImageDownload" value-ref="thumbnailController"/>
                   <entry key="bean:name=bigPreviewImageDownload" value-ref="bigThumbnailController"/>
              </map>
        </property>
        <property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/>
        <property name="assembler">
             <bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
                  <property name="interfaceMappings">
                       <props>
    	        	<prop key="previewImageDownload">
            			com.something.controller.IPDFThumbnailController
        	    	        </prop>
        	    	        <prop key="bigPreviewImageDownload">
            			com.something.controller.IPDFThumbnailController
        	    	        </prop>
            	   </props>
                   </property>
             </bean>
        </property>
        <property name="server" ref="mbeanServer"/>
    </bean>
    	
    <bean id="jmxServices" class="com.globalfilings.services.JMXServices">
         <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"/>
    </bean>
    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

    Charlie
Working...
X