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.
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)
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!!!
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.
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.
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"
Happy Friday Everyone! Today marks the international release of Disney's live action version of the animated classic Aladdin. I know that this movie was met with some controversy of over cast...
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