When embedding ActiveMQ Broker in a container, such as Tomcat or others. And if you have JMX enabled on the broker, then a RMI registry is created to allow JMX/RMI over TCP.
This uses a custom RMIServerSocketFactory that gets enlisted into the JDK RMI registry. But when you undeploy the AMQ broker, there is no API in the JDK to unregister your custom RMIServerSocketFactory class.
And therefore the JDK (system class) has a strong reference to the custom RMIServerSocketFactory, which prevents the container classloader to fully unload all classes.
Disabling JMX on the broker, allows to unload all the classes.