jetty-maven-plugin version is 9.3.27.v20190418
.
I need a JMX running during integration tests to send request to MBeans, but while JMS is starting successfully, JMX does not seem to start, as it does not appear to be listening on the designated port.
Here is a snippet of the maven config for jetty-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<!-- Reserve network ports for the integration test -->
<execution>
<id>reserve-network-port</id>
<phase>generate-test-resources</phase>
<goals>
<goal>reserve-network-port</goal>
</goals>
<configuration>
<portNames>
<portName>jetty.port</portName>
<portName>jetty.stop.port</portName>
<portName>jms.port</portName>
<portName>jmx.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<executions>
<execution>
<id>run</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy-war</goal>
</goals>
<configuration>
<jettyXml>jetty-jmx.xml</jettyXml>
<daemon>true</daemon>
<war>${project.build.directory}/project.war</war>
<webApp>
<contextPath>/project</contextPath>
</webApp>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<httpConnector>
<port>${jetty.port}</port>
</httpConnector>
<stopPort>${jetty.stop.port}</stopPort>
<stopKey>STOP</stopKey>
<contextXml>${project.basedir}/src/test/resources/context.xml</contextXml>
<webAppConfig>
<throwUnavailableOnStartupException>true</throwUnavailableOnStartupException>
</webAppConfig>
<supportedPackagings>
<supportedPackaging>jar</supportedPackaging>
</supportedPackagings>
<!-- system properties with configuration for the integration test -->
<systemProperties>
<force>true</force>
<systemProperty>
<key>jms.port</key>
<value>${jms.port}</value>
</systemProperty>
<systemProperty>
<key>com.sun.management.jmxremote</key>
<value>true</value>
</systemProperty>
<systemProperty>
<key>com.sun.management.jmxremote.port</key>
<value>${jmx.port}</value>
</systemProperty>
<systemProperty>
<key>com.sun.management.jmxremote.rmi.port</key>
<value>${jmx.port}</value>
</systemProperty>
<systemProperty>
<key>com.sun.management.jmxremote.authenticate</key>
<value>false</value>
</systemProperty>
<systemProperty>
<key>com.sun.management.jmxremote.ssl</key>
<value>false</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
And config from jetty-jmx.xml
:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Get the platform MBeanServer -->
<!-- =========================================================== -->
<Call id="MBeanServer" class="java.lang.management.ManagementFactory"
name="getPlatformMBeanServer" />
<!-- =========================================================== -->
<!-- Initialize the Jetty MBeanContainer -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New id="MBeanContainer" class="org.eclipse.jetty.jmx.MBeanContainer">
<Arg>
<Ref refid="MBeanServer" />
</Arg>
<Call name="beanAdded">
<Arg/>
<Arg>
<Get name="ILoggerFactory" class="org.slf4j.LoggerFactory"/>
</Arg>
</Call>
</New>
<New id="ConnectorServer" class="org.eclipse.jetty.jmx.ConnectorServer">
<Arg>
<New class="javax.management.remote.JMXServiceURL">
<Arg type="java.lang.String">rmi</Arg>
<Arg type="java.lang.String" />
<Arg type="java.lang.Integer"><SystemProperty name="jetty.jmxrmiport" default="1099"/></Arg>
<Arg type="java.lang.String">/jndi/rmi://<SystemProperty name="jetty.jmx.rmi.host" default="localhost"/>:<SystemProperty name="com.sun.management.jmxremote.port" default="1099"/>/jmxrmi</Arg>
</New>
</Arg>
<Arg>org.eclipse.jetty.jmx:name=rmiconnectorserver</Arg>
<Call name="start" />
</New>
</Arg>
</Call>
</Configure>
I've tested this by setting <daemon>true</daemon>
and, while jetty was running, checking the network ports, and the port designated for JMX does not appear to be listening. I've tried different jetty-jmx.xml configs, but was not able to fix the issue.