I recently had to add basic authentication to an ActiveMQ broker and run into some unexpected issues. I followed the example in ActiveMQ in Action to use the simpleAuthenticationPlugin by adding the below snippet to activemq.xml:
You can see the complete file at https://gist.github.com/881965
When I tried to start ActiveMQ with
ACTIVEMQ_HOME/bin/activemq start xbean:file:conf/activemq.xml
ActiveMQ wouldn’t start!
I checked the activemq.log and only see one line:
2011-03-22 13:21:02,799 | INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@23abcc03: startup date [Tue Mar 22 13:21:02 PDT 2011]; root of context hierarchy | org.apache.activemq.xbean.XBeanBrokerFactory$1 | main
Not very helpful…
If i comment out the simpleAuthenticationPlugin tags, activemq starts up correctly.
Hmm, what’s wrong?
Diving into the ActiveMQ In Action book further, I noticed I can start up activemq via
ACTIVEMQ_HOME/bin/activemq console xbean:file:conf/activemq.xml
This gives us a much more verbose log output.
I now see the problem is due to:
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'plugins'.
Googling up the error brings me to this page http://activemq.apache.org/xml-reference.html
** In ActiveMQ 5.4 and later, the XML elements inside broker tag have to be ordered alphabetically!
I moved the plugins tag before systemUsage tag and ActiveMQ was able to start up correctly with authentication.