0

How do I connect the Web Console to an Spring Boot embedded Artemis Server ?

I have mostly followed this Answer.

  • tomcat 9.0.58
  • activemq-web-console-5.16.3.war in webapps folder
  • added jakarta.servlet.jsp.jstl-1.2.6.jar & jakarta.servlet.jsp.jstl-api-1.2.7.jar into webapps/activemq-web-console-5.16.3/WEB-INF/lib, otherwise the console would not start
  • added the line set "JAVA_OPTS=%JAVA_OPTS% -Dwebconsole.type=properties -Dwebconsole.jms.url=tcp://localhost:61616 -Dwebconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi in catalina.bat

But now when I access the webconsole - ERROR:

  • I get Exception occurred while processing this request, check the log for more information!
  • and the logs say: IllegalStateException: No broker is found at any of the 1 configured urls

My Artemis Server is running in a minimalistic Spring Boot App:

  • started with VMOptions: -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
  • spring boot parent: spring-boot-starter-parent:2.6.2
  • active mq: artemis-jms-server:2.19.0
  • spring-boot-starter-web:2.6.2
  • and the following configuration class:
  @Configuration
  public class ArtemisConfig implements ArtemisConfigurationCustomizer {

    @Autowired
    private ArtemisProperties artemisProperties;

    @Override
    public void customize(org.apache.activemq.artemis.core.config.Configuration configuration) {
      try{

        configuration.setJMXManagementEnabled(true);
        configuration.setSecurityEnabled(false);
        configuration.addAcceptorConfiguration("netty", "tcp://localhost:" + artemisProperties.getPort());

      } catch (Exception e) {
        throw new RuntimeException("queue did not start");
      }
    }
  }
Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
aminator
  • 396
  • 7
  • 18

1 Answers1

2

The only real problem the answer you cited is that it was written for ActiveMQ "Classic" rather than ActiveMQ Artemis. ActiveMQ Artemis doesn't use activemq-web-console-5.16.3.war. It uses a web console based on Hawtio 2 which is split up across 3 different war files:

Deploy these to your embedded servlet container (e.g. Tomcat, Jetty, etc.). I don't think you'll need to set any system properties, but during the release process we actually strip out any SLF4J and Log4j jar files so you may need to add those back in if your environment doesn't already provide them. We remove those jars because we actually ship SLF4J in the main lib directory of the standalone broker, and we don't actually need Log4j (since ActiveMQ Artemis uses JBoss Logging) so it's safer to remove it (especially in the wake of all the recent Log4j CVEs). See ARTEMIS-3612 for more details on that.

The web console application running in the browser communicates with the broker via Jolokia which is an HTTP-JMX bridge. Jolokia is part of the Hawtio 2 infrastructure and is included in the aforementioned war files. If the war files are being hosted in the same JVM as your Spring Boot application with ActiveMQ Artemis embedded then you should just need to point the web console app to the same server & port you're using for the console itself. If the web console is hosted separately from the Spring Boot app then you should install Jolokia and then point the web console to it.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
  • thanks for the quick response. – aminator Feb 05 '22 at 19:55
  • I had seen your answer here already: https://stackoverflow.com/a/69105578/8574536. Unfortunately for me there is missing one piece of the puzzle. When I start this console in tomcat, how can I connect this thing to the artemis server ? There is a connect button on the screen, but I can only choose http/https schemas, but this is not provided by the artemis server. Does this console expect the artemis server to run on the very same tomcat ? Because this is not the case for me. The artemis server is running embedded in a separate spring boot app. – aminator Feb 05 '22 at 19:58
  • additionally I had to add the 2 jars `slf4j-api-1.7.33.jar` and `log4j-over-slf4j-1.7.25.jar` into the `WEB-INF/lib` folder of all those 3 war files. – aminator Feb 05 '22 at 19:59
  • again thanks for the quick response. You say `everything should be in the same JVM`, but this is exactly my point, the are `NOT in the same JVM`. The console is deployed on some tomcat, whereas the artemis server is running embedded in a separate spring boot app (with its own embedded tomcat). – aminator Feb 05 '22 at 21:31
  • now that was the missing piece of the puzzle :) thank you very much for your help and patience! Still I like to point out, that you might adjust 2 points in your answer: 1. as in my comment above, I had to add 2 jars to the tomcat (probably better to put them into `./apache-tomcat-x.x.x/lib` rather than into the `WEB-INF/lib` of each of the webapps. 2. I had to dig deeper to get aquainted with Jolokia. This answer together with the samle code helped big time: https://stackoverflow.com/a/52485928/8574536 – aminator Feb 06 '22 at 07:50
  • 1
    I updated my answer. Hope that gives final clarification! – Justin Bertram Feb 06 '22 at 23:57