Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Debugging JIRA and Confluence plug-ins via Eclipse

DanielM
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 3, 2013

I have a problem with debugging my add-ons java code through eclipse. I did some research and found a way to debug that should work:


1) Run jira/confluence with the additional parameters to open a port for debugging
atlas run --jvmargs "-Xdebug -Xrunjdwp:transport=dt_socket,address=xxxx,server=y,suspend=n"
2) In eclipse go to Run->Debug Configurations and make a newRemote Java Application where the Host is your Jira/Confluence address (i.e. localhost) and the Port is xxxx.

When I start the instance of jira with the additional parameters, I do a netstat -a | find "LIST", to check if the port is open for listening and I find that it is, but when I try to run the debug from eclipse nothing happens the 1st time, I run
netstat -a | find "LIST" again and see that the port is no longer in the list, on the 2nd attempt to debug it gives me the Failed to connect to remote VM error.

Any suggestions as to where the problem might lie? I was concidering that there is something wrong with my eclipse but I'm not sure.

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
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

With SDK 4.2.9 (on Linux in my case), the "--jvmargs" option has only effect if "jvmArgs" is NOT already set in pom.xml. "jvmArgs" from pom has priority and both are not concatenated.

You have to check "JVM Input Arguments" in target/jira/home/log/atlassian-jira.log to be sure your option has been used.

When I first run "atlas-debug" with an Atlassian plugin source code, I got:

[INFO] Starting jira on the tomcat7x container on ports 2990 (http) and 36370 (rmi)
[INFO] using codehaus cargo v1.2.3
[INFO] [cargo:start]
[INFO] [2.ContainerStartMojo] Resolved container artifact org.codehaus.cargo:cargo-core-container-tomcat:jar:1.2.3 for container tomcat7x
[INFO] [stalledLocalDeployer] Deploying [target/jira/jira.war] to [target/container/tomcat7x/cargo-jira-home/webapps]...
[INFO] [talledLocalContainer] Tomcat 7.x starting...
[WARNING] [talledLocalContainer] ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
[INFO] [talledLocalContainer] Error occurred during initialization of VM
[INFO] [talledLocalContainer] agent library failed to init: jdwp

After investigations around atlassian-jira.log (line "JVM Input Arguments") and opened ports (with netstat), I find out that atlas-run already enables JVM TI "by default" with port 8787 because of agentlib already set in "jvmArgs" for the "maven-jira-plugin".

-XX:MaxPermSize=384m -Xms1024m -Xmx2048m -Djira.dev.mode=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787

After removal of the "agentlib" option from the "maven-jira-plugin", "atlas-debug" starts properly and default port is 5005.

Update Conclusion:

  • if you have "jvmArgs" specified in your "maven-jira-plugin" in pom.xml without agentlib, run "atlas-debug" and connect to 5005
  • if you have "jvmArgs" specified in your "maven-jira-plugin" in pom.xml with agentlib options, run "atlas-run" and connect to specified port
  • if you no "jvmArgs" specified in your "maven-jira-plugin", you may run either "atlas-debug" (port 5005) or run "atlas-run" with "--jvmargs" and connect to specified port
  • in any case, check "JVM Input Arguments" in target/jira/home/log/atlassian-jira.log
DanielM
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 26, 2013

That doesn't work either :(

Alexej Geldt
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 26, 2013

im getting port 8787 when port 5005 is in use.

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 26, 2013

You should check you have no local firewall settings that prevent the port to be used

DanielM
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 26, 2013

I specifically asked the admins to open the port before trying to debug, still it didn't work.

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 26, 2013

Do you see your "agentlib" option on your JVM command-line (with Process Explorer on Windows) ? Do you see it in "JVM Input Arguments" in atlassian-jira.log ? Check for "jvmArgs" present in your plugin POM.

4 votes
Stephen Roso January 14, 2014

In case anyone else runs into this, I was having the exact same problem where the first time you click Debug in Eclipse it does nothing, then the second time it errors out.

Turns out clicking Debug does not automatically open the browser. Restart Eclipse, click Debug, then navigate to your page in the browser, and the Eclipse debug should start up. Hope that helps someone.

Marketa Dvorackova June 29, 2014

Thank you Stephen, you're my hero! Seriously, it is exactly like that. I was getting the same error. Just leave the eclipse pop-up be, doesn't matter. Once you navigate to the page in the browser and hit your action, Eclipse will start debugging. Really thanks a lot!!!

4 votes
Paul Pasler
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
September 4, 2013

Hi Daniel, i do it without any parameters, you can try "atlas-debug" and connect with eclipse.

Java Remote Application

Connection-Type: Standard (Socket Attach)

Port: 5005

Host: Localhost

DanielM
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 4, 2013

There's definately something wrong with my PC, I tried it your way and I got the same result -> port was open tried to connect and debug, port closed.

Alexej Geldt
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 16, 2013

@Daniel Milkov

works for me as Paul Pasler said. Usually you dont have to open ports yourself. When you start your instance with atlas-debug instead of atlas-run, your instance will be open for debuging on port 5005.

have a nice day

0 votes
jjaroczynski
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 4, 2013

Can you check your JIRA logs if there is anything related? Maybe something fails on JIRA side.

DanielM
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 4, 2013
jjaroczynski
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 4, 2013
  • Are JIRA and Eclipse on the same machine? Maybe firewall is the culprit?
  • Can you try to telnet to JIRA debug port and see if the connection is dropped or maybe works fine?
JamieA
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 4, 2013

I get the same thing with confluence sometimes and intellij idea - no idea why. Happens if I connect, disconnect, then connect again, or sometimes it seems like the connection is made then closed straight away. No help, just saying I doubt it's related to eclipse.

DanielM
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 4, 2013

1) Yes, they are on the same machine.

2) What exactly do I need to do there, I haven't used telnet like... ever?

jjaroczynski
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 4, 2013
telnet localhost xxxx

where xxxx is your port number. If connection is not rejected it means that JIRA port is open correctly.

Maybe port number is too high or too low and your IT guys block it somewhow with your local machine firewal rules? Please ask your IT for assistance.

DanielM
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 4, 2013

Tried to connect with telnet, it worked (didn't get refused), ran netstat to check if the port was still open after trying to connect with telnet - it was, but again when I tried to debug with eclipse the port closed.

jjaroczynski
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 4, 2013

Probably some misconfiguration is there and Eclipse does not send what JIRA/java expects.

Can you try -Xrunjdwp:transport=dt_shmem instead of dt_socket?

DanielM
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 4, 2013

Tried atlas-run --jvmargs "-Xdebug -Xrunjdwp:transport=dt_shmem,address=7777,server=y,suspend=n", I assume this is what you were talking about, tried netstat to see if the port was open for listening - it wasn't, also tried to connect with telnet localhost 7777, connection got refused and when I tried to debug with settings localhost 7777 it gave me this error (which makes sense seeing as the connection got refused when I tried it with telnet):

Failed to connect to remote VM. Connection refused.

Connection refused: connect

JamieA
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 4, 2013

shmem means used shared memory and not sockets for debugging, so you don't need to provide an address. You need to adjust the eclipse debug profile if using dt_shmem.. there should be an option for that.

DanielM
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 5, 2013

Aha, I see... I'll have to read up on that when I get to work on Monday, thanks for the clarification.

jjaroczynski
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 5, 2013

Exactly. If you work on the same machine then shared memory can do the trick.

However it does not look like Eclipse supports shared memory: http://stackoverflow.com/questions/8589883/debugging-java-application-in-eclipse-using-transport-dt-shmem

You would need to try IDEA.

DanielM
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 11, 2013

I'll try that, as soon as I can get someone from IT to install IntelliJ on my PC and I'll give feedback.

DanielM
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 16, 2013

I finally installed IntelliJ and tried debugging, here's what happened:

1) With shmem:

Error running Atlassian Debug

Unable to open debugger port : java.io.IOException "shmemBase_attach failed: The system cannot find the file specified"

2) With socket attach:

Error running Atlassian Debug: Unable to open debugger port : java.net.ConnectException "Connection refused: connect"

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events