<p>With my team we are trying to move our micro-services to openj9, they are running on kubernetes. However, we encounter a problem on the configuration of JMX. (openjdk8-openj9)
We have a connection refused when we try a connection with jvisualvm (and a port-forwarding with Kubernetes). 
We haven't changed our configuration, except for switching from Hotspot to OpenJ9.</p>

<p>The error :</p>

<pre><code>E0312 17:09:46.286374   17160 portforward.go:400] an error occurred forwarding 1099 -&gt; 1099: error forwarding port 1099 to pod XXXXXXX, uid : exit status 1: 2020/03/12 16:09:45 socat[31284] E connect(5, AF=2 127.0.0.1:1099, 16): Connection refused
</code></pre>

<p>The java options that we use : </p>

<pre><code>-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.local.only=false 
-Dcom.sun.management.jmxremote.port=1099 
-Dcom.sun.management.jmxremote.rmi.port=1099
</code></pre>

<p>We are using the last adoptopenjdk/openjdk8-openj9 docker image.
Do you have any ideas?</p>

<p>Thank you ! </p>

<p>Regards.</p>

alexis_sgra
<p>I managed to figure out why it wasn't working. 
It turns out that to pass the JMX options to the service we were using the Kubernetes service descriptor in YAML. It looks like this: </p>

<pre><code>  - name: _JAVA_OPTIONS
        value:  -Dzipkinserver.listOfServers=http://zipkin:9411 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099
</code></pre>

<p>I realized that the JMX properties were not taken into account from _JAVA_OPTIONS when the application is not launch with ENTRYPOINT in the docker container.
So I pass the properties directly into the Dockerfile like this and it works.</p>

<pre><code>CMD ["java", "-Dcom.sun.management.jmxremote", "-Dcom.sun.management.jmxremote.authenticate=false", "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.local.only=false", "-Dcom.sun.management.jmxremote.port=1099", "-Dcom.sun.management.jmxremote.rmi.port=1099", "-Djava.rmi.server.hostname=127.0.0.1", "-cp","app:app/lib/*","OurMainClass"]
</code></pre>

<p>It's also possible to keep _JAVA_OPTIONS and setup an ENTRYPOINT in the dockerfile.</p>

<p>Thanks!</p>
