In Spring 3.1 I am trying to export the same bean via JMX under two different bean names with two different interfaces.
Below is some example spring xml configuration showing what I am trying to do:
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="internal:name=internalName" value-ref="myBean"/>
<entry key="external:name=externalName" value-ref="myBean"/>
</map>
</property>
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
<property name="interfaceMappings">
<props>
<prop key="internal:name=internalName">InternalMXBean</prop>
<prop key="external:name=externalName">ExternalMXBean</prop>
</props>
</property>
</bean>
</property>
myBean implements both of the interfaces I am trying to expose via JMX.
However, when I start my application I get the exception
javax.management.InstanceAlreadyExistsException: MXBean already registered with name internal:name=internalName
Is there any way of registering the same bean instance under two different mbean names exposing a different interface?
Can you register the same MBean with more than one name? indicates that you can register the same MBean under different names but provides some reasoning as to why this could be a bad idea.
In my specific case I am using MXBeans. The same MXBean cannot be registered under different object names as this would conflict with support for inter-MXBean references.