I am trying to setup IntelliJ to connect to a Tomcat instance running in a Docker container. I would like to be able to use remote debugging and also deploy remotely using JMX.
I can enable remote debugging using the environment variables
JPDA_ADDRESS=8000
JPDA_TRANSPORT=dt_socket
and by starting Tomcat with catalina.sh jpda run
, so remote debugging works without a problem.
I can also do this alternatively with
CATALINA_OPTS='-agentlib:jdwp=transport=dt_socket,address=8000,suspend=n,server=y'
and then I don't need to use catalina.sh jpda run
No matter what I do, I cannot get JMX to work. I verified that I have catalina-jmx-remote.jar
in /usr/local/tomcat/lib`.
I have tried setting CATALINA_OPTS
and JAVA_OPTS
to
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.rmi.port=1099
-Djava.rmi.server.hostname=192.168.99.100
-Dcom.sun.management.jmxremote.ssl=false
I have verified that 192.168.99.100
is the IP of my docker machine. I have tried connecting to JMX with VisualJM and IntelliJ, it does not work. I have verified that the port 1099
is open and available from the host.
Tomcat is receiving the JMX args
20-Apr-2016 23:50:14.019 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Djava.rmi.server.hostname=192.168.99.100 -Dcom.sun.management.jmxremote.ssl=false
Why can't I get JMX to work? There is no information available in any logs and this will not work no matter what I try.
Edit: lsof -i :1099
shows nothing running on that port
I am running on Mac OS X. It is a docker-machine but I believe docker uses virualbox on mac because it can't run containers natively.
I have mapped the port. docker ps
shows 0.0.0.0:1099->1099/tcp, 0.0.0.0:8000->8000/tcp, 0.0.0.0:8080->8080/tcp
. Ports 8080
and 8000
work so 1099 should be mapped correctly too.
hostname -i
(assuming that's possible in your container), what is the result? – Winder172.17.0.3
but I assumed that I was supposed to use the IP of the machine not the container. When I ping192.168.99.100
(the IP of the docker machine), I get a response. When I ping172.17.0.3
, 100% packet loss – Slimycatalina-jmx-remote.jar
and theJmxRemoteLifecycleListener
together with thecom.sun.management.jmxremote.*
system properties. From my understanding theJmxRemoteLifecycleListener
replaces the port system properties (see here). Not sure how/if it's is supposed to work of you specifiy both... – ChemosmosisJmxRemoteLifecycleListener
. Otherwise could you add the configuration of theJmxRemoteLifecycleListener
to your question as well? – Chemosmosis