Remote Debug AEM running inside docker container using vscode | Community
Skip to main content
timdunham
Level 2
March 5, 2024
Solved

Remote Debug AEM running inside docker container using vscode

  • March 5, 2024
  • 1 reply
  • 1371 views

Hello,

I'm having a hard time getting remote debugging to work in vscode for my local AEM instance which is running inside a docker container.

I have tried various configurations and when I try to connect I get the "com.dun.jdi.connect.spi.closedconnectionexception" error ( see attached). I'm hoping someone can help spot the issue.

 

Author Dockerfile

FROM aem-base-image # Expose AEM author port 4502 and debug port 5005 EXPOSE 4502 EXPOSE 5005 # Make the container start always in Author mode with Port 4502 # ---ENTRYPOINT METHOD--- ENTRYPOINT ["java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-jar", "cq-quickstart.jar", "-Dsling.run.modes=author", "-p", "4502"]

 

Docker Compose .yml

version: '3' services: author: image: aem-author build: ./aem-author ports: - "4502:4502" - "5005:5005" publish: image: aem-publish build: ./aem-publish ports: - "4503:4503" - "5010:5010"

 

VSCODE launch.json

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "java", "name": "Attach to Remote Program - AEM Author", "request": "attach", "hostName": "localhost", "port": "5005", "projectName": "aem-my-projectName.core" }, { "type": "java", "name": "Attach to Remote Program - AEM Publish", "request": "attach", "hostName": "localhost", "port": "5010", "projectName": "aem-my-projectName.core" }, { "type": "java", "name": "Current File", "request": "launch", "mainClass": "${file}" } ] }

 

Thanks in advance. If I figure it out I'll post a follow up. For the moment I am at a loss.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by TarunKumar

Hi @timdunham ,

Can you make sure the name of Jar file is similar to what the name of your AEM author instance jar file.
The command should look something like below:

$ java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar aem-author-p4502.jar

 

Also in your docker yml file double check if build and image configuration value is correct?

Thanks
Tarun

1 reply

TarunKumar
Community Advisor
TarunKumarCommunity AdvisorAccepted solution
Community Advisor
March 6, 2024

Hi @timdunham ,

Can you make sure the name of Jar file is similar to what the name of your AEM author instance jar file.
The command should look something like below:

$ java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar aem-author-p4502.jar

 

Also in your docker yml file double check if build and image configuration value is correct?

Thanks
Tarun

timdunham
timdunhamAuthor
Level 2
March 6, 2024

@tarunkumar - Thanks for taking a look.

While its typical to name your jar file using the run mode and the port I am just using the generic name from the base image and then specifying the port and mode using parameters which does work. Its running in author mode and is accessible on 4502 so I am not sure changing that part of my setup would help the issue I am facing.  Its only the debug port that is giving me the issue.

I do see you have "*:5005" which is a bit different than how I specify the port. I will try that and see of it helps. I think I tried it already but I'll try it one more time.