It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Debugging JIRA and Confluence plug-ins via Eclipse

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

1 vote
Answer accepted

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

That doesn't work either :(

im getting port 8787 when port 5005 is in use.

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

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

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.

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

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.

@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

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.

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!!!

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

  • 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?

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.

1) Yes, they are on the same machine.

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

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.

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.

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?

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

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.

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

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.

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

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"

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

We want to hear from you! How do you use Slack and Atlassian together?

Hi Everyone! My name is Mina and I am on Atlassian’s Ecosystems Marketing team. Our team is focused on our technology partnerships and marketplace apps. One of Atlassian’s partners is Slack, who ...

44 views 0 4
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you