Details
Description
I am using ActiveMQ as part of a web-app deployed to Tomcat. Active MQ is configured via spring and follows the spring examples that you ship with the source in M4. If I configure the broker to use JMX ( <broker useJmx="true"> ) and deploy the app to tomcat, everything goes fine. However, when I deploy a newer version of the app (hot deploy) I get the following error when the JMS consumer is created from spring:
006-02-20 15:16:17,378 ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:205) Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'smsResponseConsumer' defined in ServletContext resource [/WEB-INF/applicationContext-messaging.xml]: Initialization of bean failed; nested exception is javax.jms.JMSException: org.apache.activemq:Type=Topic,Destination=ActiveMQ.Advisory.Connection,BrokerName=localhost
javax.jms.JMSException: org.apache.activemq:Type=Topic,Destination=ActiveMQ.Advisory.Connection,BrokerName=localhost
And the root cause of this exception is:
Caused by: javax.management.InstanceAlreadyExistsException: org.apache.activemq:Type=Topic,Destination=ActiveMQ.Advisory.Connection,BrokerName=localhost
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at org.apache.activemq.openwire.DataStreamMarshaller.createThrowable(DataStreamMarshaller.java:199)
at org.apache.activemq.openwire.DataStreamMarshaller.unmarsalThrowable(DataStreamMarshaller.java:159)
at org.apache.activemq.openwire.v1.ExceptionResponseMarshaller.unmarshal(ExceptionResponseMarshaller.java:67)
at org.apache.activemq.openwire.OpenWireFormat.doUnmarshal(OpenWireFormat.java:214)
at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:181)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:135)
... 1 more
So it appears as if the JMX entry isn't "unbound" when the applicaiton restarts on a redeploy.
If I set JMX to false then I can redeploy the application without any errors.