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

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

  •  02-06-2022
  •  | 
  •  

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
有帮助吗?

解决方案

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"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top