Setting debug configuration for maven+jetty+eclipse - eclipse

I have created a web app using maven in eclipse. I am using jetty for running the app.
I am able to run the app using the maven jetty plugin. But I am facing difficulty while debugging the app -
The steps that i have followed to setup debug settings are from the below link
http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together-with-hot-deploy/
I can run the app at port 8080 and it keeps on Listening for transport dt_socket at address: 4000. For debugging i have given port 4000. But when i start the debugger in eclipse it gives me a window with following error -
"Failed to connect to remote VM. Connection refused.
Connection refused: connect"
Can some one help me out in resolving this issue for debugging the app.
Thanks!!!

Set MAVEN_OPTS using -
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
Then start jetty using -
mvn jetty:run
Start remote debugging from your fav IDE on port 8000

Here's a quick workaround. I was battling with this problem also and after a while I achieved a lazy solution.
I use Eclipse Indigo with m2eclipse. I created a new Run Configuration: Right-Clicked the project in Project Explorer -> Run As... -> maven build. Then I defined the necessary maven commands/goals to run the project with jetty straight from Eclipse.
Finally I just ran the newly created configuration in Debug mode and got debug working. This probably messes up something else(?) but works as a quick workaround.

As suggested by h3xstream in one of the comments, you can run using mvnDebug jetty:run.

As mentioned by Pascal Thivent in this answer, since Maven 2.0.8 one can use mvnDebug in the following way:
mvnDebug jetty:run
This will start maven in debugger mode on port 8000.

Related

Debugging Maven build in Eclipse 2022

Aim: I have a Maven application that does not have any JUnit testcases. I want to debug the app.
Setup: I choose the Maven plugin maven.surefire.debug. I have specified the plugin details in the Run-->DebugConfigurations. After adding breakpoints, when I run the app in debug mode, rather than Listening at default port 5005, the app runs to completion.
Query: How to make the app listen at port 5005 and eventually stop at breakpoint? Please help me in resolving the issue.

How to debug a play framework 2.2.5 application in eclipse ide?

I am new to play framework.I want to debug my application in eclipse.I tried with some solutions using google search.But it does not helps me.Please tell me how to debug a play application in eclipse and at production level also.For all help thanks in advance.
I am using SBT to compile and run my Scala Play application, if you are as well, this might help you.
What I do is on command line set SBT_OPTS like so:
set SBT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999
Then when you sbt run it will wait for a debugger to attach on socket port 9999.
I use the Scala IDE to develop and debug my application.
In after you've run sbt run you attach the Scala IDE by creating a new Remote Java Application debug configuration specifying Scala debugger (Socket Attach) and setting the port to 9999 (host should be localhost by default). Then click on debug and you should be up and debugging.

How to debug remote OSGi bundle?

I'm completely new to OSGi and I'm working on the development of an OSGi bundle and I want to debug my code (set breakpoints, step by step run, variable lookup, ...).
I have my virgo server listening on port 8001.
How can I do that ?
I'm using Springsource Tool Suite 3.0 and my bundle is running on a remote virgo server.
Thanks for any hint you can give me.
Marco.
Take a look at this answer,
I'm sure that one will help you on this also:
Remote Debugging in eclipse

eclipse + maven + tomcat debugging

I'm developping a web application in Eclipse and I'm using maven, spring and tomcat.
Now the problem I have is that debug as => debug on server doesn't work.
I just get exceptions. (and yes I've created the server)
If I use the mvn command to compile it, put the war in my tomcat webapps dir and start my tomcat the application works fine. But for the functionallity I'm now working on debugging would be usefull.
I found the answer for this in http://jacksonps4.me/wordpress/?p=868
Worked like a charm for me, yet I don't understand anything!
We used to test our application with Tomcat as well, but switched to starting an embeddable Jetty. Here's a sample app. It's JSF, but it doesn't really matter. The pseudo-unit test simply starts a jetty "before" and shuts stops it "after". No need for external server infrastructure, no need for IDE dependencies.
you can run tomcat with maven with this command:
mvn tomcat:run
and if you want to debug, set this maven options:
export MAVEN_OPTS=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
if you are in windows, use the set command:
set MAVEN_OPTS=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
then you can debug with eclipse Remote Java Application.
Hope this help.

Can I debug an application which is running on other eclipse instance?

I have two eclipse instances running.
And in one I have the code base.
And in other eclipse i am running the application.
So can I debug this application in the eclipse where I have code base?
I imagine your build produces a JAR file? if so, then you can run the JAR from the console and then plug the eclipse debugger.
Check this tutorial, that is clear and with screenshots
You should be able to launch a remote debug session
1/ Specify the following option when launching the app from the first eclipse
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
2/ Launch a Remote Java App (Run > Debug> Debug Configurations... > Remote Java Application.)
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
(if port 8000 is free) in order to debug the app from the "code base" eclipse.
See Remote Debugging with Eclipse.
You can specify the sources in the Remote Java App configuration by referencing your own code base.
Yes, you can attach the debugger to a remote JVM. See How to attach debugger to running process?