using VSCode for AEM Sites Java development | Community
Skip to main content
jayv25585659
Level 8
May 17, 2024
Solved

using VSCode for AEM Sites Java development

  • May 17, 2024
  • 2 replies
  • 5095 views

I've been using IntelliJ CE but I want to try using VSCode.

 

1 thing I always  do is to create 2 debug configuration (Remote JVM) for author and publisher. I'm trying to do this in VSCode but it seems to recognize only 1.

 

I first created 1 debug configuration in launch.json and that was working well. I can do breakpoints in my code. I tried adding another 1 for publisher (everything is the same except for name and port) and I see no way of selecting the 2nd debug configuration.

 

Any ideas on how to do it? Thanks

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 HrishikeshKagne

HI @jayv25585659 ,

Yes, you can use VSCode for AEM Sites Java development. Here are the steps to create multiple debug configurations for author and publisher:

  1. Open your AEM project in VSCode.

  2. Open the Debug view by clicking on the Debug icon in the left-hand sidebar.

  3. Click on the "create a launch.json file" link to create a new launch configuration file.

  4. In the launch.json file, create a new configuration for the author instance by adding the following code:

 

{ "type": "java", "name": "AEM Author", "request": "attach", "hostName": "localhost", "port": 30303 }

 

  1. Create a new configuration for the publisher instance by adding the following code:

 

{ "type": "java", "name": "AEM Publisher", "request": "attach", "hostName": "localhost", "port": 30304 } ​

 

 

  1. Save the launch.json file.

  2. Start your AEM author and publisher instances.

  3. In VSCode, select the "AEM Author" configuration from the dropdown in the Debug view and click on the "Start Debugging" button.

  4. Set breakpoints in your code and test the author instance.

  5. Stop the author instance and select the "AEM Publisher" configuration from the dropdown in the Debug view.

  6. Click on the "Start Debugging" button to start debugging the publisher instance.

Note: Make sure that the port numbers in the launch.json file match the port numbers of your AEM author and publisher instances. Also, ensure that the AEM instances are running and accessible before starting the debugging session

2 replies

HrishikeshKagne
Community Advisor
HrishikeshKagneCommunity AdvisorAccepted solution
Community Advisor
May 18, 2024

HI @jayv25585659 ,

Yes, you can use VSCode for AEM Sites Java development. Here are the steps to create multiple debug configurations for author and publisher:

  1. Open your AEM project in VSCode.

  2. Open the Debug view by clicking on the Debug icon in the left-hand sidebar.

  3. Click on the "create a launch.json file" link to create a new launch configuration file.

  4. In the launch.json file, create a new configuration for the author instance by adding the following code:

 

{ "type": "java", "name": "AEM Author", "request": "attach", "hostName": "localhost", "port": 30303 }

 

  1. Create a new configuration for the publisher instance by adding the following code:

 

{ "type": "java", "name": "AEM Publisher", "request": "attach", "hostName": "localhost", "port": 30304 } ​

 

 

  1. Save the launch.json file.

  2. Start your AEM author and publisher instances.

  3. In VSCode, select the "AEM Author" configuration from the dropdown in the Debug view and click on the "Start Debugging" button.

  4. Set breakpoints in your code and test the author instance.

  5. Stop the author instance and select the "AEM Publisher" configuration from the dropdown in the Debug view.

  6. Click on the "Start Debugging" button to start debugging the publisher instance.

Note: Make sure that the port numbers in the launch.json file match the port numbers of your AEM author and publisher instances. Also, ensure that the AEM instances are running and accessible before starting the debugging session

Hrishikesh Kagane
jayv25585659
Level 8
May 18, 2024

let me try. I was not aware (it was not obvious) there's a a dropdown list in debug view. thank you.

BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
May 18, 2024

Try to add configurations for both the author and publisher (below). In the Debug view, there should be a dropdown menu at the top where you can select the debug configuration. You should see both "AEM Author" and "AEM Publisher" listed here.

 

  • Ensure your launch.json looks something like this:
{ "version": "0.2.0", "configurations": [ { "type": "java", "name": "AEM Author", "request": "attach", "hostName": "localhost", "port": 30303 }, { "type": "java", "name": "AEM Publisher", "request": "attach", "hostName": "localhost", "port": 30304 } ] }

 Start debugging:

  • Select the "AEM Author" configuration from the dropdown and click the green play button to start debugging.
  • Set your breakpoints and interact with the author instance.
  • When you want to switch to the publisher, stop the current debugging session, select "AEM Publisher" from the dropdown, and click the play button again.

I hope this helps!