To debug an AEM6.5 instance in IntelliJ IDEA, you can follow these steps:
- Start the AEM6.5 instance in debug mode: In the AEM Quickstart folder, locate the
start.bat
(Windows) orstart.sh
(Linux/Mac) file, and add the following parameter-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
to the command. For example:java -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -jar cq-quickstart-6.5.0.jar
This will start AEM6.5 in debug mode, listening on port 8000.
- Create a remote debug configuration in IntelliJ IDEA:
- Go to “Run” > “Edit Configurations” from the main menu.
- Click on the “+” button to add a new configuration.
- Select “Remote” from the list of configurations.
- Set the name to “Debug AEM”.
- Set the “Debugger mode” to “Attach”.
- Set the “Host” to “localhost”.
- Set the “Port” to “8000” (or whatever port you configured in step 1).
- Start the remote debug configuration:
- Select the “Debug AEM” configuration from the list of configurations.
- Click on the “Debug” button to start the configuration.
- Set breakpoints in IntelliJ IDEA:
- Open the Java file that you want to debug.
- Click on the line number where you want to set the breakpoint.
- Trigger the code that you want to debug in AEM:
- Navigate to the page that you want to debug in AEM.
- Perform the action that triggers the code that you want to debug.
- Debug the code in IntelliJ IDEA:
- IntelliJ IDEA will stop at the breakpoint that you set.
- Use the “Step Over”, “Step Into”, and “Step Out” buttons to navigate through the code.
- Use the “Variables” and “Watches” windows to inspect variables and expressions.