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