Expand my Community achievements bar.

SOLVED

Remote Debug AEM running inside docker container using vscode

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

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

Avatar

Level 2

@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.

Avatar

Level 2

Update!!

Using the below port format seems to have fixed my issue at least with the base 6.5 install

 

" *:5005 "

 

On all my earlier tests I was running a service pack but I cant imagine that will make a difference.

I really appreciate the help! Thanks!