How to debug written jira plugins from Eclipse?

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

This widget could not be displayed.

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.

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

Thank you very much! :)

This widget could not be displayed.

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.

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?

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

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

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<

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

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

Andris Bērziņš

Thank you ...its working for me

This widget could not be displayed.

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

me too. Any solutions?

This widget could not be displayed.

Hi,

I just used the IDEA IDE and it works :)

Maybe there is a error in eclipse.

Best regards,

Andi

This widget could not be displayed.

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

This widget could not be displayed.

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?

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.

This widget could not be displayed.

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.

This widget could not be displayed.

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.

This widget could not be displayed.

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.

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

This widget could not be displayed.

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.

This widget could not be displayed.

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

514 views 3 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you