JBoss remote debug ports
I am trying to remote debug a legacy application (JBoss 4) that is within a docker container. I can debug it if I run it natively on the local machine but I need to package it up inside docker. All the articles that I can find just end at getting debugging working on the remote port such as 8787. That works as I can connect and debug using JDB from the command line but so far after more than 12 hours I still haven't been able to work out what extra steps IDEA needs.
So, in addition to whatever debug port, it looks like it needs 1099 for remote naming, but does it need any others?
Output from 'docker port' showing the mapped / exposed ports:
> docker port jboss-dev
1199/tcp -> 0.0.0.0:1199
8180/tcp -> 0.0.0.0:8180
8787/tcp -> 0.0.0.0:8787
Output showing open ports in the container:
root@58b7d5d37e33:/# lsof -i -P -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 28 root 8u IPv4 204434 0t0 TCP 172.18.0.3:8787->172.18.0.1:46046 (ESTABLISHED)
java 28 root 98u IPv4 203517 0t0 TCP *:8183 (LISTEN)
java 28 root 101u IPv4 203522 0t0 TCP *:1199 (LISTEN)
java 28 root 102u IPv4 204441 0t0 TCP *:1198 (LISTEN)
java 28 root 105u IPv4 204455 0t0 TCP *:38147 (LISTEN)
java 28 root 108u IPv4 204456 0t0 TCP *:45851 (LISTEN)
java 28 root 110u IPv4 204457 0t0 TCP *:43863 (LISTEN)
java 28 root 113u IPv4 204458 0t0 TCP *:4444 (LISTEN)
java 28 root 115u IPv4 203531 0t0 TCP *:4445 (LISTEN)
java 28 root 117u IPv4 203532 0t0 TCP *:4446 (LISTEN)
java 28 root 124u IPv4 204463 0t0 TCP 172.18.0.3:3873 (LISTEN)
java 28 root 198u IPv4 203542 0t0 TCP *:8180 (LISTEN)
java 28 root 199u IPv4 203543 0t0 TCP *:8109 (LISTEN)
java 28 root 214u IPv4 204471 0t0 TCP *:8193 (LISTEN)
java 28 root 293u IPv4 204478 0t0 TCP 172.18.0.3:49144->172.18.0.2:5432 (ESTABLISHED)
java 28 root 318u IPv4 204510 0t0 TCP 172.18.0.3:49146->172.18.0.2:5432 (ESTABLISHED)
root@58b7d5d37e33:/#
As we can see, JBoss is listening on considerably more ports that just 8180 (my application), 8787 (remote debugging) and 1199 (JNDI). And it also shows that IDEA has connected to the remote debugging port, but I don't get anything helpful from the IDE.
I get "Unable to connect to the localhost: 1199, reason: javax.naming.CommunicationException: null" this is despite 1199 being exposed.
So do I need to expose any other ports for this to work? My fear is that there might be some automated port opening going on which on a firewall would require something like "allow established" but I don't know if you can do that within docker? I know what some of these extra ports are for (remote shutdown etc.) but by no means all.
In the meantime I am investigating / trying to enable admin login within JBoss to see if that helps.
My current machine is Mac OS (Catalina latest) running Docker Desktop but the whole point of this is to make it machine agnostic.
In the open ports above, 5432 can be ignored - that is the jboss container talking to a postgres DB on another container.
Please sign in to leave a comment.
Hi Martin,
I submitted this issue to our tracker as IDEA-251858. You can follow it for updates from the responsible developer.
See this article if you are not familiar with YouTrack.
Thank you - I am watching the issue.
OK, this has taken way, way longer than it should have done - but then my experience is that anything to do with remote debugging always does!
It turns out that the RMI hostname was not set. I have never tried to debug a truely remote computer before so I have never messed about with any of this but in my configuration for JBoss I added the hostname like as below. This is needed since as far as JBoss is concerned docker isn't local so it becomes a truly remote machine. Docker networking provides automatic hostname lookup by container name. Once the hostname was set in the JBoss startup configuration I also needed to change IDEA to refer to it by that hostname, which in turn meant I also needed to set that hostname to 127.0.0.1 in my MacOS hosts file.
FINALLY, it connects and I (presumably) can debug - I will try tomorrow.
Tidying up, and answering my original question, in addition to the debugging port of 8787 and RMI port which is 1099 by default, 1199 in my case I also needed to expose ports 1198 (1098 by default) and 4544 which is I believe the RMI Object binding port. This was the minimum number of ports that I could expose from the docker container and have remote debugging still work.
My ports are all 8180, 1199, 1198 etc. because I am using "ports-01" instead of "ports-default" in the bindings.xml
I have updated my original post above with the correct port numbers since I had been changing them so much they were inconsistent in my original post.
Thanks for the details Martin.
I will update this thread later too with the result of the investigation.