Configuring xsbt-web-plugin to open JMX and allow MBean inspection with JConsole/VisualVM

StackOverflow https://stackoverflow.com/questions/17487394

  •  02-06-2022
  •  | 
  •  

Pergunta

How can I configure xsbt-web-plugin to open JMX port so I can inspect MBeans with Jconsole or VisualVM?

With my current setup VisualVM displays no MBean saying "the JMX connection could not be established".

I'm guessing the desired result would be xsbt-web-plugin invokes jetty in the lines of:

java
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.port=1099 
-jar start.jar etc/jetty-jmx.xml etc/jetty.xml
Foi útil?

Solução

Because xsbt-web-plugin does not fork a Java process when you run container:start, there's no way to use sbt's javaOptions to do this. Instead, you'll have to instrument the sbt process itself to see any JMX info.

To do this, add the following line to your ~/.sbtconfig file:

SBT_OPTS="$SBT_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=1099"
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top