0

We have system tests and when they start an Embedded Jetty boots via the setup. The Embedded Jetty includes a JMX server, too. Then we have tests which must connect to the JMX Server via:

JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:<JMX_PORT>/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

The problem is we cannot connect from the tests to the JMX server when we do not know the JMX port up front. Has anybody a clue how to specify the JMX port up front when the Embedded Jetty is built within the source code? The system property stuff is of no help here.

kladderradatsch
  • 596
  • 5
  • 18
  • so you want to have the JVM's JMX port be configurable? or you want to get the active JVM JMX port so you can use it? – Joakim Erdfelt Jul 27 '18 at 15:38
  • Possible duplicate of https://stackoverflow.com/questions/27508185/is-it-possible-to-enable-remote-jmx-monitoring-programmatically – Joakim Erdfelt Jul 27 '18 at 15:43
  • @JoakimErdfelt: We need to know the port when we try to connect within the test - very simple. When we not configure it the port up-front we don't have the chance to connect - a port is always required. It is just magic and obscure how e.g. JConsole can do this. – kladderradatsch Jul 31 '18 at 14:42
  • Ah, in that case this question was likely answered by https://stackoverflow.com/questions/13252914/how-to-connect-to-a-local-jmx-server-by-knowing-the-process-id and https://stackoverflow.com/questions/35842/how-can-a-java-program-get-its-own-process-id – Joakim Erdfelt Jul 31 '18 at 16:04

0 Answers0