Issue
I'm trying to connect my debugger to Wildlfy running on Open JDK 11.
Despite Wildfly says:
Listening for transport dt_socket at address: 8787
My IDE (IntelliJ IDEA CE 2018.1) claims that it doesn't get any connection:
Unable to open debugger port (localhost:8787): java.io.IOException "handshake failed - connection prematurally closed"
.
I'm starting Wildfly via standalone.sh --debug
resulting in the following JAVA_OPTS
:
-server
-Xms64m
-Xmx512m
-XX:MetaspaceSize=96M
-XX:MaxMetaspaceSize=256m
-Djava.net.preferIPv4Stack=true
-Djboss.modules.system.pkgs=org.jboss.byteman
-Djava.awt.headless=true
-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED
--add-modules=java.se
Did something change in Java 9/10/11? Remote debugging with the exact same setup works fine when using Oracle JDK 8.
Using telnet I can confirm, that port 8787
is indeed not reachable.
Update after reading @ehsavoie's comment: netstat -ln
on the server running Wildfly shows:
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:8787 0.0.0.0:* LISTEN
So apparently with OpenJDK 11 the debug port is now bound to localhost by default.
Solution
The cause lies in the default behaviour that changed with Java 9 according to this answer: Beginning with Java 9, the JVM only accepts local connections unless otherwise specified.
Therefore the solution is fairly easy:
While with Java 8 it is sufficient to start Wildfly with --debug
, with Java 9 I needed to change this to --debug *:8787
.
Answered By - Sebastian S
Answer Checked By - Katrina (JavaFixing Volunteer)