How to debug random ports used by JBoss EAP
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.x
- 6.x
- 5.x
- 4.x
Issue
JBoss EAP appears to be using ephemeral / random ports. How can I find out what is using the ports?
Resolution
Since it is suspected that JBoss is using ephemeral/random ports, remove any custom deployed applications in order to rule out the possibility that the application is opening ports. Install Byteman and download the attached file, byteman-script.zip, which contains the file ports.btm
Linux
EAP 7.x (standalone) - Edit standalone.conf and add
JAVA_OPTS="$JAVA_OPTS -Dorg.jboss.byteman.transform.all -javaagent:$BYTEMAN_HOME/lib/byteman.jar=script:ports.btm,boot:$BYTEMAN_HOME/lib/byteman.jar,listener:true"
EAP 6.0.x (standalone) - Edit standalone.conf and add
JAVA_OPTS="$JAVA_OPTS -Dorg.jboss.byteman.transform.all -javaagent:$BYTEMAN_HOME/lib/byteman.jar=script:ports.btm,boot:$BYTEMAN_HOME/lib/byteman.jar,listener:true"
EAP 5.x & 4.x - Edit run.conf and add
JAVA_OPTS="$JAVA_OPTS -Dorg.jboss.byteman.transform.all -javaagent:$BYTEMAN_HOME/lib/byteman.jar=script:ports.btm,boot:$BYTEMAN_HOME/lib/byteman.jar,listener:true"
Windows
EAP 6.0.x - Edit %JBOSS_HOME%/bin/standalone.conf.bat and add the byteman parameters
set "JAVA_OPTS=%JAVA_OPTS% -javaagent:%BYTEMAN_HOME%/lib/byteman.jar=script:%BYTEMAN_HOME%/scripts/ports.btm,listener:true,boot:%BYTEMAN_HOME%/lib/byteman.jar -Dorg.jboss.byteman.transform.all"
EAP 5.x & 4.x - Edit run.conf.sh and add
set "JAVA_OPTS=%JAVA_OPTS% -javaagent:%BYTEMAN_HOME/lib/byteman.jar=script:%BYTEMAN_HOME%/scripts/ports.btm,listener:true,boot:%BYTEMAN_HOME%/lib/byteman.jar -Dorg.jboss.byteman.transform.all"
Start the JBoss EAP instance and check the console for stacktraces generated by the byteman script. The stacktraces will show which component/service is using the port.
NOTE: Open a Red Hat support ticket and attach the resulting output should you need further assistance from Red Hat.
Attachments
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments