Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Unable to establish debug connection to localhost

Avatar

Level 3

Hi,

I have installed crx-quickstart.jar in my local. localhost:4502/aem/start.html is up and running.

When i try to connect to the server in the debug mode from eclipse, it throws following error:

could not establish debug connection to localhost : 30303
Failed to connect to remote VM. Connection refused.
Connection refused: connect

Eclipse is running in AEM Perspective 

When I connect to server in run mode it's all good.

Connection Details:

Port: 4502

DebugPort: 30303

 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @schallag ,

Start your AEM instance using command-prompt/terminal using below command 

java -Xmx512m -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n -jar cq-author-p4502.jar -Dsling.run.modes=author -nofork

Once the server is up then try to connect to the port 30303 and it will connect.

View solution in original post

10 Replies

Avatar

Correct answer by
Employee Advisor

Hi @schallag ,

Start your AEM instance using command-prompt/terminal using below command 

java -Xmx512m -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n -jar cq-author-p4502.jar -Dsling.run.modes=author -nofork

Once the server is up then try to connect to the port 30303 and it will connect.

Avatar

Community Advisor

Hi @schallag ,

 

You can either enable debug mode from the command prompt while running the JAR or change the JVM opts in the start batch file. Both options have been described below-

 

https://rashidjorvee.blogspot.com/2018/12/how-to-start-aem-in-debug-mode.html

https://experienceleague.adobe.com/docs/experience-cloud-kcs/kbarticles/KA-17459.html?lang=en

Avatar

Employee Advisor

Please refer the below details and update the port number as per your need -

 

Go to bin folder in crx-quickstart and change the line 25 in start.bat by adding the highlighted part here (address port number can be any number of your choice)

if not defined CQ_JVM_OPTS set CQ_JVM_OPTS=-Xmx1024m -XX:MaxPermSize=256M -Djava.awt.headless=true -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10123

Change line no. 44 by adding this

set CQ_RUNMODE=%CQ_RUNMODE%,crx3,crx3tar,debug

Save the file.

Once saved open the command prompt, go to \crx-quickstart\bin and type “start.bat”, once it’s done you’ll see another window of cmd being opened and the server will start in debug mode as seen below

DEBAL_DAS_0-1650427723613.png

 

Check if the server is started or not by opening localhost:4502 in the browser

Setting up the debug config in eclipse

Go to Run -> Debug Configurations -> Remote Java Application

Set up a new configuration like seen below by selecting the project (mostly it’ll be core) and click Debug

DEBAL_DAS_1-1650427723628.png

 

Check if Debug is working fine or not by having the Debug view

DEBAL_DAS_2-1650427723643.png

 

 

Eclipse by default will suspend execution on uncaught exceptions which will debug the code which we haven’t even selected. This will waste our time. So please do this to avoid it

Go to Windows - > Preferences -> Java -> Debug and uncheck “Suspend execution on uncaught exceptions”

DEBAL_DAS_3-1650427723650.png

 

Set debug points in your code and explore!

Avatar

Level 3

Hi , I tried what's mentioned here in the comments. I see the local host is up and running in Debug view. 

But when i click the debug button in Debug configurations, It throws the below error. Please Advice.

schallag_1-1650479652700.png

 

 

Avatar

Level 1

Hello,

Please try simple command while opening your AEM instace:

 

Java -jar <yourjarname-4502>.jar -debug <debugport> 

and when open the file from eclipse- ctrl+shift+R  - add debug points in file opened from as highlighted below,

open the java file from .core 

kajalinamdar1_0-1650432376896.png

 

And you can see the threads running for debugging in debug perspective.

kajalinamdar1_1-1650432540159.png

 

Please let me know if this helps.

Thanks!

 

Avatar

Level 3

Hi , I tried what's mentioned here in the comments. I see the local host is up and running in Debug view. 

But when i click the debug button in Debug configurations, It throws the below error. Please Advice.

schallag_0-1650479466213.png