From 56bfd8da9da10cdb76ad18dc829029c992eb4899 Mon Sep 17 00:00:00 2001 From: francisca eze Date: Fri, 16 Apr 2021 10:35:17 +0100 Subject: [PATCH 1/4] add docs to connect java debugger to a springboot docker-compose application --- README.md | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/README.md b/README.md index eaa640d3..2b0f9f97 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,119 @@ The script `load.py` (requires Python 3) can be used to restore from such JSON d The optional parameter `--no-commits` can be added to skip those entries that look like a commit ID. Note that this might break previous permalinks. + +# CONNECTING JAVA DEBUGGER WITH DOCKER COMPOSE + +Connecting to a java debugger can be broken down into the following steps: +###1. Run the application using docker-compose +Create a Dockerfile_debug at the root of the directory with the same content as the Dockerfile of the application + +Create a docker-compose-debug.yml file with the same content as the docker-compose.yml file at the root of the directory replacing this in the docker-compose-debug.yml +```yaml + image: commonworkflowlanguage/cwlviewer:v1.3.0 +``` + +with this: + +```yaml +build: + context: . + dockerfile: Dockerfile_debug +``` +This is because we want docker to build with our source code on our local instead of the image on docker hub. + +In the port section we want to specify a different port to listen to debug connections. + +Here, we are using address as 5005. + +In the command section as well, we configure JVM to allow debugging and We enable the agent Java Debug Wire Protocol (JDWP) inside the JVM. + +At the end you should have something looking like this + +```yaml +build: + context: . + dockerfile: Dockerfile_debug +ports: + - "8080:8080" + - "5005:5005" +command: java -Djava.security.egd=file:/dev/./urandom -jar /usr/lib/cwlviewer.jar +``` +If on intellij, open the docker-compose-debug.yml and click on the ![img_2.png](img_2.png) in the gutter. + +You should see this message: + + “Compose: docker-compose-debug.yml has been deployed successfully” + +you can access the application on localhost port 8080(which is the default port here) and the application should start up as expected. + +You can make HTTP requests on it and expect it to work + +###2. Create a remote debug config +In the docker-compose-debug.yml, click on the “insect looking image”, ![img_1.png](img_1.png) on the side gutters + +Select the module in the Use module classpath list, in this case “cwlviewer” + +Double-click the Docker Compose run configuration in the Before launch list. + +If it is not in the list, click + and select Launch Docker before debug + +Make sure that the Docker Compose run configuration is selected with the app service. + +Also check the Custom Command field: it should contain the -agentlib option and options from the command field in the docker-compose-debug.yml file: + + java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Djava.security.egd=file:/dev/./urandom -jar /usr/lib/cwlviewer.jar + + +####NB +If the default port is allocated to something else, change the container port for the Java debugger to connect to and make sure that the port in the remote debug configuration is the same. + +If the application is already running, do not run the debug configuration. Apply the settings and click Cancel. + +###3. Launch the debug configuration +If the application is already running, stop it. + +This can be done by selecting the Docker Compose node in the Services tool window below and click ![img.png](img.png)in the toolbar. + +You can also right-click and delete the containers under the corresponding services. + +Open the docker-compose-debug.yml file. + +Click ![img_3.png](img_3.png) Debug with Remote in the gutter and start the debug configuration. + +Once the application starts and the debugger attaches to it, the Debug tool window will open. + + ### 4. Setting breakpoints and Debugging the application + +Open the file to be debugged and set breakpoints at different points in the method + +Execute the http request + +The application will stop at the breakpoint and you can examine the current variable values and frames in the Debug tool window. + +Click ![img_4.png](img_4.png) until it executes the request and you get the returned values. + +You can also step into, step over or step out of methods depending on your preference. + + + + + + + + + + + + + + + + + + + + # Documentation From 61547777eb4b9613bef95377635682b0cc60b5bb Mon Sep 17 00:00:00 2001 From: francisca eze Date: Fri, 16 Apr 2021 10:35:46 +0100 Subject: [PATCH 2/4] add images to used in docs --- img.png | Bin 0 -> 214 bytes img_2.png | Bin 0 -> 188 bytes img_3.png | Bin 0 -> 274 bytes img_4.png | Bin 0 -> 184 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 img.png create mode 100644 img_2.png create mode 100644 img_3.png create mode 100644 img_4.png diff --git a/img.png b/img.png new file mode 100644 index 0000000000000000000000000000000000000000..df33e31f791191abbbdd43383843077d56a32f78 GIT binary patch literal 214 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`b3I)gLn`8u6BdYi+{nrj*njsI zv%vrM#1c~$#w!A!csp*V?QKY5-nV3f9>c}L+iUq6Od5F_E7?O;#TYLAQJu=1BkU1; z$80sHfu(@_LLu&k%r;2}A%|-`$28ac?mW1I*CW-|fyd2)@vMLdXApyzLf&?-j{AA0 z@@nn|0*MSM935^;7+3$iAW_-BY7&P-n3EHmh-&JL%_q$oA{ZFNzpu%zvY&Ss=uiev LS3j3^P6o literal 0 HcmV?d00001 diff --git a/img_2.png b/img_2.png new file mode 100644 index 0000000000000000000000000000000000000000..f3e6c27b4b72a4429bccd8566b5af3f726fe7e9d GIT binary patch literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a)4W=|K#kcznE1O@gT=eQ#p`uiDU zp0oWcpDDiMeqvn%gP9#0gC@gc%f{!jX{-`E&hTY9JX^flJ%izK!*{*S%rXrnO{eD^ z;5V?7<1OgrOt^humO{-UlZKoFs~J<2&Uhv~clcRw^n}!$=WHe3^$lt%{i6->;*c9!PC{xWt~$(697LZL`47q literal 0 HcmV?d00001 diff --git a/img_3.png b/img_3.png new file mode 100644 index 0000000000000000000000000000000000000000..3b6e91da5a71d2745121b1136b377d69ced3e032 GIT binary patch literal 274 zcmV+t0qy>YP)l|^&|8NqL%)Dhf3H*o~r0DHxj@+kbsC6_#oyYenTmaUE4 z&_=ZCkzZ*SG&?)Z-iy6SICG;uQqvnVh#6XZ=psZ-xzwsdu&3&vabFS#L)${rt3M!S zzY+Hb$XY$oGaVidfd}OIY-(O6&pQm=$DPM|Sq+H@xM9~f-iTQkI)kz9Dp-x@|F3{G zg)UFwNi!8>OSj}Jg;+Fn^v2l=_FA@T&+}_kD62sCDNjRo{fqbT{0P7Q;qHT&lfBo# Y7h+@zRuFvt0RR9107*qoM6N<$g1wA%u>b%7 literal 0 HcmV?d00001 diff --git a/img_4.png b/img_4.png new file mode 100644 index 0000000000000000000000000000000000000000..799a4b6406b6ceeba672b527c4d5aa771cc21fb4 GIT binary patch literal 184 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`^`0({Ar*1S2@)X(O7kAnOSE2U5!dm?staG~8z} hy3FXQS(w4ZU^975hu#joVxUtPJYD@<);T3K0RTVHK8gSU literal 0 HcmV?d00001 From 20534cb2833d083f8dee3c2556c458043273f6da Mon Sep 17 00:00:00 2001 From: francisca eze Date: Fri, 16 Apr 2021 10:36:28 +0100 Subject: [PATCH 3/4] add bug image --- img_1.png | Bin 0 -> 274 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 img_1.png diff --git a/img_1.png b/img_1.png new file mode 100644 index 0000000000000000000000000000000000000000..3b6e91da5a71d2745121b1136b377d69ced3e032 GIT binary patch literal 274 zcmV+t0qy>YP)l|^&|8NqL%)Dhf3H*o~r0DHxj@+kbsC6_#oyYenTmaUE4 z&_=ZCkzZ*SG&?)Z-iy6SICG;uQqvnVh#6XZ=psZ-xzwsdu&3&vabFS#L)${rt3M!S zzY+Hb$XY$oGaVidfd}OIY-(O6&pQm=$DPM|Sq+H@xM9~f-iTQkI)kz9Dp-x@|F3{G zg)UFwNi!8>OSj}Jg;+Fn^v2l=_FA@T&+}_kD62sCDNjRo{fqbT{0P7Q;qHT&lfBo# Y7h+@zRuFvt0RR9107*qoM6N<$g1wA%u>b%7 literal 0 HcmV?d00001 From 79e83ff8e3d1474a3d06d11fe5e00f377fdd5e03 Mon Sep 17 00:00:00 2001 From: francisca eze Date: Tue, 20 Apr 2021 10:24:34 +0100 Subject: [PATCH 4/4] add changes to documentation --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2b0f9f97..3d099bbc 100644 --- a/README.md +++ b/README.md @@ -164,10 +164,10 @@ The script `load.py` (requires Python 3) can be used to restore from such JSON d The optional parameter `--no-commits` can be added to skip those entries that look like a commit ID. Note that this might break previous permalinks. -# CONNECTING JAVA DEBUGGER WITH DOCKER COMPOSE +# CONNECTING JAVA DEBUGGER WITH DOCKER COMPOSE USING INTELLIJ IDE Connecting to a java debugger can be broken down into the following steps: -###1. Run the application using docker-compose +### 1. Run the application using docker-compose Create a Dockerfile_debug at the root of the directory with the same content as the Dockerfile of the application Create a docker-compose-debug.yml file with the same content as the docker-compose.yml file at the root of the directory replacing this in the docker-compose-debug.yml @@ -211,7 +211,7 @@ you can access the application on localhost port 8080(which is the default port You can make HTTP requests on it and expect it to work -###2. Create a remote debug config +### 2. Create a remote debug config In the docker-compose-debug.yml, click on the “insect looking image”, ![img_1.png](img_1.png) on the side gutters Select the module in the Use module classpath list, in this case “cwlviewer” @@ -227,12 +227,12 @@ Also check the Custom Command field: it should contain the -agentlib option and java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Djava.security.egd=file:/dev/./urandom -jar /usr/lib/cwlviewer.jar -####NB +#### NB If the default port is allocated to something else, change the container port for the Java debugger to connect to and make sure that the port in the remote debug configuration is the same. If the application is already running, do not run the debug configuration. Apply the settings and click Cancel. -###3. Launch the debug configuration +### 3. Launch the debug configuration If the application is already running, stop it. This can be done by selecting the Docker Compose node in the Services tool window below and click ![img.png](img.png)in the toolbar.