I am having the exact same problem using Spring 3. It would be great if anyone has a solution to this. I can manually specify the beans and they show up in jmx-console. But Spring is not picking up my mbeans automatically.
Here is my configuration on JBoss that works just as dkarr describes:
Code:
<bean id="mbeanServer" class="org.jboss.mx.util.MBeanServerLocator" factory-method="locateJBoss" />
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="server" ref="mbeanServer" />
<property name="autodetect" value="true" />
<property name="assembler" ref="assembler" />
</bean>
<bean id="jmxAttributeSource"
class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />
<!-- Will create management interface using annotation metadata. -->
<bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
<property name="attributeSource" ref="jmxAttributeSource" />
</bean>
<!-- Will pick up the ObjectName from the annotation. -->
<bean id="namingStrategy"
class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
<property name="attributeSource" ref="jmxAttributeSource" />
</bean>
And here is the class I am trying to export:
Code:
@ManagedResource(objectName="com.so.config:name=WebConfig", description="Web Application Configuration")
public class WebConfig {
private String protocol;
@ManagedAttribute(defaultValue="https")
public String getProtocol() {
return protocol;
}
@ManagedAttribute(defaultValue="http")
public void setProtocol(String protocol) {
this.protocol = protocol;
}
}