How to debug written jira plugins from Eclipse?

Bahar Çağlar October 10, 2012

Hi,

I have started developing jira plugins using Eclipse enviroment.

I use atlas-run to check my plugin. But I want to debug my code with breakpoints.

I tried atlas-debug for this, but the breakpoints didint work.

How can I do this? Can anyone suggest something?

Thanks for answers

11 answers

1 accepted

11 votes
Answer accepted
Nahn Yanootz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 21, 2013

I've got a simple solution, and you can pick any port you want.

(Debugging on port 5005 didn't work for me either)

Step 1 - Edit catalina.bat:

Go to your atlassian-jira-x.x.x-standalone/bin and open catalina.bat in an editor.

Find the following chunk of code:

rem set _EXECJAVA=%_RUNJAVA%
rem set MAINCLASS=org.apache.catalina.startup.Bootstrap
rem set ACTION=start
rem set SECURITY_POLICY_FILE=
rem set DEBUG_OPTS=
rem set JPDA=

and replace it with:

set _EXECJAVA=%_RUNJAVA%
set MAINCLASS=org.apache.catalina.startup.Bootstrap
set ACTION=start
set SECURITY_POLICY_FILE=
set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=7456,server=y,suspend=n
set JPDA=

Notice that address=7456 means that this port will be available for debugging. You can use any other port you want.

Step 2 - Add external run configuration in Eclipse

  • Go to Run -> Debug Configurations...
  • Create a new Remote Java Application run configuration: (right click Remote Java Application -> New)
  • Make sure your Project: option is set to your Jira plugin project.
  • Set your Connection Type: to Standard (Socket Attach).
  • Under Connection Properties, put in your host (in my case localhost ), then specify your port. (in my case 7456)

Now you have your debugging mechanism all set up. After you start jira, just run this debugging configuration (Debug As -> Debug Configurations -> Your configuration) and place your breakpoints wherever you need them.

praveen reddy October 6, 2013

Hi, i have tried it, but it is not working ..

Alexander Pampushko December 15, 2015

Thank you very much! :)

7 votes
Andris Bērziņš
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2012

Hello,

When JIRA starts after you ran atlas-debug, in Eclipse go to Run -> Debug Configurations. There should be an option "Remote Java Application" - rightclick and create new. Set the port for 5005 and start debugging.

Bahar Çağlar October 11, 2012

1. I run the command: atlas-debug

[INFO] jira started successfully in 29s at http://localhost:2990/

2. Then debug

3. But I get the following error:
Failed to connect to remote VM. Connection timed out. org.eclipse.jdi.TimeoutException
Ho can I fix the problem?
Andris Bērziņš
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 11, 2012

As I already said in my answer - set the port to 5005.

Bahar Çağlar October 14, 2012

I tried with port 5005, but it didnt work :( I am getting the same error.

Failed to connect to remote VM. Connection refused. Connection refused

Maybe, the port is wrong? I run it as http://bahar:2990/jira , for this host will be bahar, and port will be 5005 again, right? for this case, I am getting the same error.

The problem is eclipse?

Thanks

Bahar Çağlar October 14, 2012

Also, when ı tried http://localhost:5005/, I am getting the following error:

[INFO] [talledLocalContainer] Debugger failed to attach: handshake failed - received >GET /cargocpc/< - excepted >JDWP-Handshake<

HarryH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2013

Hi, Bahar,

localhost:2990 is for viewing jira instance through website, and 5005 port is the one used to attach the socket to listen on, so thesed two ports are separated.

That means when opening jira via web brower, use localhost:2990, when debugging your plugins, please use 5005 in the debug settings.

Thank

Harry

MB
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2013

Thanks Andris. Nice, simple and easy. Worked out-of-the-box. +1 :)

Jagadeeswar Chirasani January 18, 2018

Andris Bērziņš

Thank you ...its working for me

Arthur
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2018

Thanks Andris, this works like a charm!

This is a game changer for me XD

4 votes
Andreas Hilmer October 12, 2012

Hi,

I just used the IDEA IDE and it works :)

Maybe there is a error in eclipse.

Best regards,

Andi

4 votes
Andreas Hilmer October 11, 2012

Hi,

I have got the same problem. The port 5005 is selected but I get the same error. Also I can't access localhost:5005 through my webbrowser.

Any ideas?

Best Regards,

Andi

Bahar Çağlar October 11, 2012

me too. Any solutions?

0 votes
Kevin Ross February 12, 2015

The debug options changed in JVM 5.0, and it appears from an examination of the command that they are issuing old debug options:

-Xdebug -Xrunjdwp:transport=dt_socket,address=5005,suspend=n,server=y

I'm using Java 8 and simply get connection refused.  I telnet and verify there is nothing listening on 5005.  It seems that atlas-debug needs to be updated, that or tomcat's catalina.sh.

See:

http://stackoverflow.com/a/173447/2363935

 

I checked the catalina.sh options in the build directory, and they are correct.  It appears that atlas-debug must be building the command line and not allowing the catalina.sh to form the proper jdwp arguments

0 votes
amiddleton June 17, 2014

Hi

This may be nothing, but I found that I couldn't connect to port 5005 via Eclipse (got connection refused error). Originally I started JIRA just by typing 'atlas-debug', but then when I tried atlas-debug --product jira --version 6.1 I could then get Eclipse to work.

0 votes
Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2014

I could somehow set the debug running. But how do we debug a plugin with no main method in it. I did set some breakpoints but i wasnt able to debug the application properly. Whereever i set the breakpoints the debug seems to be not hitting the code. Any help? I downloaded the code of JIRA Bar chart plugin.

Dipti Ranjan Behera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2014

@jayashree: have you attached the jira bar chart plugin code to the debug configuration.

0 votes
Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2014

i am still facing the issue. i have attached the screenshot. Can anyone please help me out ? Even when i configure it to 5005, on atlas-debug the application starts at 2990. I am not able to debug the plugin properly.

0 votes
Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2014

i am still facing the issue. i have attached the screenshot. Can anyone please help me out ? Even when i configure it to 5005, on atlas-debug the application starts at 2990. I am not able to debug the plugin properly.

0 votes
Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 7, 2014

Hi ,

I am too facing the same problem as Andreas Hilmer when using eclipse. I have followed all the steps as mentioned. My JIRA app uses 2990 and for debug i used 5005. However after choosing debug configuration and selecting debug i get the error "Launching the application failed. Failed to connect to vm. Connection refused.

Can anyone please help me resolving this issue?

Yves Martin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 7, 2014

Please read the following instructions to diagnose yourself what may be wrong: https://answers.atlassian.com/questions/208296/debugging-jira-and-confluence-plug-ins-via-eclipse?page=1#214145

Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2014

I am still facing the issue. It says connection time out

. I have eclipse and jira in the same machine. I configured the eclipse as

Run -> Debug Configurations

Then selected the "Remote Java Appilcation". and configured as given in screenshot.

0 votes
Yves Martin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2013

Please read the following instructions to diagnose by yourself what may be wrong:

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events