In my Spring application (which is deployed on WebLogic server) I have the following Spring beans definitions:
<context:mbean-server />
<bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="SpringBeans:name=hibernateStatisticsMBean,subsystem=${subsystem}" value-ref="hibernateStatisticsMBean" />
</map>
</property>
</bean>
<bean name="hibernateStatisticsMBean" class="org.hibernate.jmx.StatisticsService">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
It registers new MBeans when application is being deployed and works perfectly. However, when I undeploy the application and deploy it again it complains about MBean being there already.
How can I automatically unregister MBean during application undeploy? Can it be done through Spring or do I need to do some WebLogic magic for that?