Search code examples
javaactivemq-artemishawtio

Embedded ActiveMQ Artemis web console loading incorrectly


I am running an embedded instance of ActiveMQ Artemis and have been running into some trouble getting the web console to behave correctly.

In order to get the console to run I followed these instructions.

This successfully starts the console and I can login based on the username and password I set in my login.config file. However, when navigating through the console I noticed I am missing many of the navigation bars on the top of the console (queues, session, producers, etc.) as you can see in the image below and I'm not entirely sure why.

enter image description here

An additional problem that might help diagnose what is going on include the fact that just going to consoleHost:8161 pulls up the below result but consoleHost:8161/console correctly redirects to the login page. However, these might be unrelated problems enter image description here

Looking through the JavaScript files that are included in the decompressed artemis-plugin.war directory (specifically \tmp\webapps\artemis-plugin.war\webapp\plugin\js\components\navigation.js) I noticed that the inclusion of these are based on the MBean server so my leading theory is that instead of setting the MBean server to ManagementFactory.getPlatformMBeanServer() I should be setting it to something more specific to Artemis but I'm not sure what that would be.

Comparing the console logs of a locally running, standalone Artemis instance that correctly displays the console and my embedded implementation the only difference in initialization that stands out is that the working logs have the line:

[hawtio-jmx-rbac] Using mbean hawtio:type=security,area=jmx,name=ArtemisJMXSecurity for client-side role based access control

and my broken implementation instead has the line:

[hawtio-jmx-rbac] Using mbean hawtio:type=security,area=jmx,rank=0,name=HawtioDummyJMXSecurity for client-side role based access control

Not sure if any of this helps but any pointers to what could be wrong would be greatly appreciated as I have been scratching my head for awhile trying to get the console to work correctly on my embedded artemis instance.

EDIT:

Updating my answer with the code I added to the original instructions

ActiveMQSecurityManager securityManager = server.getActiveMQServer().getSecurityManager();
ManagementContextDTO managementDTO = new ManagementContextDTO();
ManagementContext managementContext = ManagementFactory.create(managementDTO, securityManager);
server.getActiveMQServer().getManagementService().registerHawtioSecurity(managementContext.getArtemisMBeanServerGuard());

I placed these lines after the line webServerDTO.addBinding(bindingDTO); and before webServerComponent.configure(webServerDTO, pathToArtemis, pathToArtemis);

I believe this just enables default security configuration as I never defined a management.xml file but hopefully this is enough to help anyone with the same problem


Solution

  • The artemis plugin requires a running ManagementContext, you can extract the steps to start the ManagementContext from https://github.com/apache/activemq-artemis/blob/2.32.0/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java#L86

    The console supports the rootRedirectLocation attribute to set the location to redirect the requests with the root target, see https://activemq.apache.org/components/artemis/documentation/latest/web-server.html#embedded-web-server