I have a maven project which I m trying to execute using mvnDebug clean install command but it is getting stuck at below point and nothing happens after this:
mvnDebug clean install
Preparing to execute Maven in debug mode
Listening for transport dt_socket at address: 8000 (Stucked here and nothing happens after this)
Debug configuration in Eclipse is shown in image:
Also if I am trying to debug from java class itself by right clicking and selecting Debug as > Debug configurations (same configuration as shown in image) > debug then it is working fine just for the first time and opening the debug perspective. But If i perform the same actions I get "Launching remote encountered a problem, failed to connect to remote VM.Connection refused".
Related
I have created a java micronaut application in Eclipse IDE. The microservice is able to build and run successfully via commandline but I'd like to know if there is a way to add breakpoints in the application for debugging just the way we debug any normal java application?
I did try the solution mentioned here Debug java micronaut microservice in visual studio code.
I added run.jvmArgs('-Dmicronaut.environments=dev','-noverify', '-XX:TieredStopAtLevel=1', '-Xdebug',"-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n", '-Dcom.sun.management.jmxremote') configuration
to build.gradle.
When I build and run the project again, I see
> Task :run
Listening for transport dt_socket at address: 8000
12:53:51.084 [main] INFO i.m.context.env.DefaultEnvironment - Established active environments: [dev]
12:53:53.809 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 3102ms. Server Running: http://localhost:6030
So how do I add breakpoints and debug the microservice now?
In this setup, the JVM is listening on a socket for a debugger to attach. In Eclipse, you can create a remote debug configuration for this:
Run -> Debug Configurations
Make new Launch configuration under Remote Java Application
Ensure the right project is selected. Under Connection Properties, let it connect to localhost on port 8000 (which happens to be the default)
Click Debug
I am using IntelliJ to develop a Scala project.
Due to client-server architecture of the system, my integration tests have to be run with the following settings in build.sbt:
fork in IntegrationTest := true
javaOptions in (IntegrationTest) ++= Seq("-Djdk.logging.allowStackWalkSearch=true", "-XX:PermSize=256M", "-XX:MaxPermSize=512M", "-Xmx1024m")
// for attaching with debugger to the processes under test
javaOptions in (IntegrationTest) += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
Normally everything works fine - tests are being run, debugging works.
Sometimes I need to establish a VPN connection to access some resources of my employee company. I'm using Check Point Endpoint Security VPN (that's the officially recommended software of my employee and I'm not sure if anything else would work).
So, if I happen to be connected to the VPN and then run the integration tests, then SBT console starts getting stuck right after:
Listening for transport dt_socket at address: 5005
The exact message is:
Listening for transport dt_socket at address: 5025
[error] Uncaught exception when running tests: java.net.ConnectException: Connection timed out: connect
[trace] Stack trace suppressed: run last project/it:test for the full output.
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
When I run last project/it:test (I have to reload SBT console first because it has stuck in (busy) > state) I see this:
[debug] javaOptions: List(-Djdk.logging.allowStackWalkSearch=true, -XX:PermSize=256M, -XX:MaxPermSize=512M, -Xmx1024m, -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005)
[debug] Forking tests - parallelism = false
[debug] Create a single-thread test executor
[error] Uncaught exception when running tests: java.net.ConnectException: Connection timed out: connect
Sometimes when I disconnect the VPN and run the tests again, it starts working. But often disconnecting VPN doesn't help and I have to reboot my computer.
I have tried some less dramatic solutions - restarting IDE, killing all java and javaw processes, looking at netstat results to see anything still using the port 5005, changing the port to 5025 in build.sbt and reloading SBT console... nothing works, only reboot and only until the next time I need to connect to VPN.
That's a nightmare. I don't want to reboot my machine each time after I connect to VPN.
Is there any solution to this? Any Java flags? Any Windows network stack settings? Any VPN settings?
I'm running my Spring Boot application with debug mode enabled. Like:
mvn -P dev spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
I can debug the application after that without any problem. But, after stopped (ctrl + c) and try to start again, I receive this error:
[INFO] Attaching agents: []
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
So, every time that I need to start the application in debug mode after that, I need to kill the process using the port 5005.
I would like to know why the port 5005 is still opened after stop the application.
I'm using Cygwin64 on Windows 10, Maven 3.5.2, Java 8 and Spring Boot 1.5.9.RELEASE.
Thanks!
This is not a problem of Spring Boot, but a problem of non-cygwin applications running in cygwin. And your application is not only leaving port 5005 open, it just keeps running in the background, having port 8080 also opened, but as on a restart the debug port is first opened, this is what you see in the error message.
This was discussed in a SpringBoot issue back in 2014 https://github.com/spring-projects/spring-boot/issues/773. I cite from this issue (the link in the citation dates from 2006):
Anyone still following this bug, this isn't a Spring Boot bug at all. It's a known problem with non-Cygwin programs (Java in this case) running on pty-based terminals.
See this link for a full explanation why this can't be fixed: http://cygwin.com/ml/cygwin/2006-12/msg00151.html
So you can basically use one of the following approaches:
use the native windows terminal and setup your java and maven environment for that
run your maven command from within an IDE which can handle this - you might use this for debugging as well
add the Spring Actuator to your app and use the /shutdown endpoint to stop your application
I know that this answer was asked before, but I couldn't find a clear solution from the given answers.
I want to debug a maven project that implements a web service on tomEE using IntelliJ or any other IDE.
I know that instead of calling the goal tomee:run I must call tomee:debug. And that's what I did:
In IntelliJ, I click on Run / Edit Configurations then +, I chosen Maven, I located the project directory and I set tomee:debugas command line. I started the debug and it says:
Started server process on port: 8080
Listening for transport dt_socket at address: 5005
I think this first step is correct. The second step as I understood is to create a remote configuration, and this is what I failed to do.
What I did is the following:
Run / Edit Configurationsthen +, then TomEE Server. Here I choose local or remote? In my case I think local because the project is local on the device and I call it using localhost:8080.
After that, how to configure this page? What will be the port number 5005 or 8080? And when I finish configuring this page what I do? Run or debug?
I would appreciate a detailed answer because I was not able to understand the short answers given on other questions.
Here's the solution:
Step 1:
In IntelliJ, I click on Run / Edit Configurations then + to add a new configuration, I chosen Maven, I located the project directory and I set tomee:debugas command line. I started the debug and it says:
Started server process on port: 8080
Listening for transport dt_socket at address: 5005
An alternative solution can be by locating the project directory in terminal and running the command: mvn tomee:debug
Step 2: In IntelliJ, I click on Run / Edit Configurations then + to add a new configuration, I chosen Remote, and I specify localhost with port 5005.
Now I click OK, and I debug this configuration.
Breakpoints are detectable and debugging works perfect.
I am trying to debug my client side code which i have checked-out from SVN to eclipse workspace. My server process is already up and running. I have a start-up script for our client which has the following line to start the client.
jre/bin/java splash:images/initializing.png -classpath "$CLASS_PATH" in.co.xxx.xxx.yyy.yyy.launcher.Launcher $* &
I added the debugging related arguments to it
jre/bin/java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=9045,suspend=n -splash:images/initializing.png -classpath "$CLASS_PATH" in.co.xxx.xxx.yyy.yyy.launcher.Launcher $* &
In Eclipse i went to debug configurations entered the hostname and port number(same i mentioned in the startup script (9045)). I added all the client related classes in source tab of debug configurations. Now comes the problem.
When i click debug button after all this, the remote debugger should be launching and waiting for the connection when i fire my start-up script. But it is saying
Failed to connect to remote VM. Connection refused.
Connection refused
I have tried with different port numbers as well. Nothing seems to work. Please suggest what am i missing here .
Did you check Eclipse logs to see if anything further got logged there? Also, when you say debug did not launch 'post authentication page', did you see on the 'server side' if there is a message to 'standard output' stating that the debug port is 'released'? (something similar to this would be emitted on standard output). If this did not show up, then the 'first successful connection' might not have actually released the debugger while you think it did.
Also this works for me here, the only difference I see is that the order of parameters in your and my debug switch are different. Hope this helps!
-Xdebug -Xrunjdwp:transport=dt_socket,address=8080,server=y,suspend=n