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.
Related
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.
I have a Advanced Java Application(Spring+Hibernate) with Maven. Project runs without any error.
I follow below process to test the application.
Build War using below command.
C:\Dev\ProjectApp> mvn clean package -Dmaven.test.skip=true
This builds war file inside target folder(C:\Dev\ProjectApp\target).
Place Application.war inside webapps folder(C:\Apps\Apache\Jakarta\Tomcat6\webapps)
run startup.bat from Tomcat6\bin folder.
hit the application in web Browser (http://localhost:8080/).
I want to debug this application from eclipse IDE itself. While application runs in webbrowser. I want to debug using breakpoints.
What are the steps to run this application in eclipse? What are constraints involved in this?
Thanks in Advance !
To simply debug the flow of the application, you can use the eclipse as the basis.
Goto the server view and create a new tomcat server (or any server that you use for dev). Next right-click on your project --> run as --> run on server and select the server that you just created. Keep in mind that the server should have all the configurations that you need to have to run the application. If your project requires some custom settings in the application server, then tell eclipse to take control of the server installation by selecting "Use Tomcat installation". (double click on the server to configure it)
Next add debuggers and start the server from within eclipse.
Happy debugging !
Set the environment variables first
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
You can edit the startup.bat to have
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
and start in the same way as above.
After this you can have your eclipse open a remote debugging session that connects to localhost:8000.
However, I would strongly recommend to use the WTP plugin in eclipse to build and start/stop the tomcat from within eclipse itself.
I have a maven project. I am trying to run a single test in maven command line and that works fine. I am trying to debug that test in eclipse and using -Dmaven.surefire.debug option and starting a debug on port 5005 as "Remote Application" in maven - ref http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html
Now when I do so - as part of my maven command in command line all classes/test-classes, spring config get compiled and put in right places. However when I am Run Debug from eclipse when the test pauses to listen on port 5005 - I see eclipse is running a maven build all over again and all classes are recompiled. And while doing this it is not picking up all the profiles required for the test as not all profiles are active by default. I could fix that by Project->Properties->Maven and set the active Maven profiles there.
What I am looking for if why is eclipse trying to do a maven build when I am trying to run my test for which a compiled class is already present? Is that a default behaviour of eclipse maven plugin m2e? And can this be turned off - so that it only executes the class instead of trying a maven build?
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.
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?