M. Stefanczuk
M. Stefanczuk

Reputation: 356

Attach IntelliJ IDEA debugger to a remote java -server running process

I run Java appliaction on Ubuntu virtual machine with command:

java -showversion -server -Xmx512M -Drps.home=${RPS_HOME} \
-Dcontainer.host=${CONTAINER_HOST} \
-Djava.util.logging.config.file=$4 \
-classpath ${RPS_LIBS} com.softel.rps.impl.core.SPEngine ${CONFIG} \
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999

I opened port 9999 with command (an also forwarded port in VirtualBox):

sudo ufw allow 9999/tcp

And I try to attach debugger with IntelliJ IDEA: IDEA debug

And finally i end up with error

IOException "handshake failed - connection prematurally closed"

Im not very well experienced in remote debugging. Can you tell me is it possible to attach debugger to java -server process?

Upvotes: 2

Views: 5221

Answers (2)

Melih
Melih

Reputation: 1

Start your application with the command below:

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar .\your_app.jar -showversion -server

and start a remote debugger from your idea (mine is the idea):

Edit Configuration > (+) add Remote JVM Debug with default option :)

enter image description here

Upvotes: 0

Egor
Egor

Reputation: 2674

Try to specify -agentlib options before everything else:

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999
-showversion -server -Xmx512M -Drps.home=${RPS_HOME} \
-Dcontainer.host=${CONTAINER_HOST} \
-Djava.util.logging.config.file=$4 \
-classpath ${RPS_LIBS} com.softel.rps.impl.core.SPEngine ${CONFIG}

Upvotes: 3

Related Questions