Hi,
I am using Spring3.1
I am getting the exception InstanceAlreadyExistsException when I try to add bean to the JMX context.
I am using annotations in order to add this bean. how could I over pass this excpetion and register both my instances to the jmx?
my code:
xml:Code:@ManagedResource(objectName = "ba.f:name=kkk", description = "") public class SessionsManagerBean { .. }
jmx configuration:
Code:<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean" /> <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> <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"> <property name="assembler" ref="assembler" /> <property name="namingStrategy" ref="namingStrategy" /> <property name="autodetectModeName" value="AUTODETECT_ASSEMBLER" /> <property name="ensureUniqueRuntimeObjectNames" value="false" /> <property name="beans"> <map> <entry key="Server:name=HttpAdaptor"> <bean class="mx4j.tools.adaptor.http.HttpAdaptor"> <property name="port" value="8000" /> <property name="host" value="0.0.0.0" /> <property name="processor"> <bean class="mx4j.tools.adaptor.http.XSLTProcessor" /> </property> </bean> </entry> </map> </property> <property name="listeners"> <list> <!-- let the HttpAdapter be started after it is registered in the MBeanServer --> <bean class="com.fixgw.jmx.HttpAdaptorMgr"> <property name="mbeanServer" ref="mbeanServer" /> </bean> </list> </property> </bean>
bean instances xml configuration:
error:Code:<bean id="SessionsManager1" class="com.fixgw.sessions.SessionsManagerBean"> </bean> <bean id="SessionsManager2" class="com.fixgw.sessions.SessionsManagerBean"> </bean>
Code:Caused by: javax.management.InstanceAlreadyExistsException: ba.f:name=kkk at com.sun.jmx.mbeanserver.Repository.addMBean(Unknown Source) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(Unknown Source) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(Unknown Source) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(Unknown Source) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(Unknown Source) at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(Unknown Source) at org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(MBeanRegistrationSupport.java:169) at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:655) at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:592) ... 18 more
thanks,
ray.


Reply With Quote
