Remote debug dockerized Vertx App in Eclipse

335 views
Skip to first unread message

xiaoxi pang

unread,
Nov 8, 2016, 4:00:23 PM11/8/16
to vert.x


I'm trying to put the vertx app inside the docker container and want to use Eclipse to remote debug the app when needed.

First question, I'm not fully understand this paragraph in the vertx core manual. It would be nice if there will be a example for remote debug configuration and replugin configuration

To debug your application, create your run configuration as a remote application and configure the debugger using --java-opts. However, don’t forget to re-plug the debugger after every redeployment as a new process is created every time.

How to do the re-plug? 

Second question, I think that my Eclipse actually be able to connect with the vertx app docker container. However, none of the breakpoints can be hit some how.

So here is the details:
1. I create a dockerfile which will install the gradle and copy in the source code, then in the end, gradle will use shadowJar to create the fat jar and I try to add the java-opts debug and hot redeploy when running the fatjar (I use the openjdk8 image instead of vertx3 image):

CMD (gradle shadowJar &&  java -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n -jar build/libs/lrp-vertx-3.3.3-fat.jar --redeploy="src/**/*.java" --on-redeploy='gradle shadowJar')

Then I try to run the docker by exposing my app port and debug port at the same times

docker run --rm -it  -v $(pwd):/somepath -p 8081:8081 -p 8000:8000 lrp-vertx-dev

The docker container runs properly which listening to the 8000 and redeploy mode

 
Starting a Gradle Daemon (subsequent builds will be faster)
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:shadowJar UP-TO-DATE
BUILD SUCCESSFUL
Total time: 3.649 secs
Listening for transport dt_socket at address: 8000
Nov 08, 2016 8:12:26 PM io.vertx.core.impl.launcher.commands.Watcher
INFO: Watched paths: [/home/xpang/Documents/Projects/lrp-vertx-template/lrp-vertx/./src]
Nov 08, 2016 8:12:26 PM io.vertx.core.impl.launcher.commands.Watcher
INFO: Starting the vert.x application in redeploy mode
Starting vert.x application...
efb79038-9d71-4ca4-a0c6-897e91c99363-redeploy
The Verticle startsNov 08, 2016 8:12:27 PM io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer
INFO: Succeeded in deploying verticle

I check the app in the browser, it can display the hello world message. As well, when I change the title, the hot redeploy works well.

In the Eclipse, I create Debug Configuration with Connection Properties Host:localhost, Port:8000
I run this debug mode, it will connect with the server, but not be able to hit any breakpoints I set


In the above image, I feel like the debug connection is established, but all the breakpoints I set inside the start method can not be hit when I load the page in browser.

I go through the Vert.x Github gradle/docker examples and understand that in most case gradle will trigger the whole build and even docker image generation. However, I want to isolate the vertx application build inside the container, so I didn't user gradle plugin to trigger the docker managements. As well, I didn't use the gradle wrapper because in the container, it still need to download the gradle which is similar to directly install.

Do anyone can help to point out where am I wrong? Really appreciate!


Steffen Reichert

unread,
Nov 9, 2016, 5:12:15 AM11/9/16
to ve...@googlegroups.com
If you want to debug something on the startup of the vertx app, you have to start it by using option …suspend=y… so then it runs on your connect, and you will be able to reach your breakpoints in the start method.

Greets
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/02229761-9af5-4dec-ba77-032f7aece213%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

xiaoxi pang

unread,
Nov 9, 2016, 9:30:23 AM11/9/16
to vert.x
Thanks for the reply! I've tried to change that to suspend=y, but all the breakpoints can not be hit.

Clement Escoffier

unread,
Nov 9, 2016, 11:15:47 AM11/9/16
to ve...@googlegroups.com
Hi,

You need to put "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n” in the —java-opts. This is because of the redeploy, as it spawns a new process (and kill it, restart it when a change is detected. 

Clement


xiaoxi pang

unread,
Nov 9, 2016, 12:00:15 PM11/9/16
to vert.x
Hello, clement

I've put the commands inside the docker file

CMD (gradle shadowJar &&  java -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n -jar build/libs/lrp-vertx-3.3.3-fat.jar --redeploy="src/**/*.java" --on-redeploy='gradle shadowJar')

But it still doesn't work. Debug mode will not auto trigger as well as all breakpoints will not be hit.

I've try to remove the " --redeploy="src/**/*.java" --on-redeploy='gradle shadowJar"  and keep the java-opts in my dockerfile. Then in the eclipse when I try to remote debug, it doesn't work. However, when I try to change some line of code, there will be a popup jump out saying that hot swap gonna not work. But after that if I refresh the page in the browser, the eclipse will auto jump to the debug mode. That's pretty weird. 

Xiaoxi

Clement Escoffier

unread,
Nov 9, 2016, 1:34:41 PM11/9/16
to ve...@googlegroups.com
Hi,

On 9 Nov 2016, at 18:00, xiaoxi pang <pangx...@gmail.com> wrote:

Hello, clement

I've put the commands inside the docker file

CMD (gradle shadowJar &&  java -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n -jar build/libs/lrp-vertx-3.3.3-fat.jar --redeploy="src/**/*.java" --on-redeploy='gradle shadowJar’)

Try with:

CMD (gradle shadowJar &&  java  -jar build/libs/lrp-vertx-3.3.3-fat.jar --redeploy="src/**/*.java" --on-redeploy='gradle shadowJar’ —java-opts="-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n”)


Clement

xiaoxi pang

unread,
Nov 9, 2016, 1:44:40 PM11/9/16
to vert.x
It works! Thank you so much!!!

Xiaoxi
Reply all
Reply to author
Forward
0 new messages