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.
Related
i have tried the webservice example mentioned in the below link.
https://codezone4.wordpress.com/2012/11/08/restful-web-services-java-mysql-and-json/.
i build the application with maven deployed in tomcat then clicked on the webservice link in the chrome , not able to access my code.
Now i tried to debug with postman .
I clicked on my webservice class -> then debug -> debug configiuration
then i selected remote application
there values of host and port are
Host : localhost
Port : 8080
then it is showing establishing connection for long time and after that it is showing Failed to connect to remote vm .connection timedout
Can you please guide me how to make deugger working in eclipse to debug the rest api call.
I can find quick solution (In Windows Environment with local host):
1) Download tomcat in your favorite drive (E.g. d: drive)
2) Open startup.bat file under tomcat/bin folder in notepad
3) Replace following line (Which appear at the end of file)
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
with
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
4) Restart your tomcat as it will start with listening port 8000
5) Open Eclipse->"Run"->"Debug configuration"-> Create "Remote Java Application" and provide following information:
Name: sample-name
Project: your project folder
6) Click on Debug button
Note: Make sure Connection properties will have
Host: localhost
Port: 8000
7) Put debug point in your code
8) Open Postman and Hit sample REST API call as you will see the debug point will appear in your code
That's It!
Quoting from your query,
clicked on my webservice class -> then debug -> debug
The project you created requires the restApplication to be deployed on a running server.
Prior To Testing -> check http://localhost:8080 is up or not, and then publish the war into the server.
choose Debug As-> Debug on Server
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 am new to jboss and myeclipse.
I want to debug my web app using jboss 4.0.4
I am using MyEclipse.
I gone through various links and found we need to uncomment following line in run.bat file
set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
then after starting run.bat console shows
Listening for transport dt_socket at address: 8787
Then next how do I tell MyEclipse to attach to port 8787 and run my application in debug mode.
You need to define a Remote Java Application in the Eclipse debug configurations:
Open the debug configurations (select project, then open from menu run/debug configurations)
Select Remote Java Application in the left tree and press "New" button
On the right panel select your web app project and enter 8787 in the port field.
Here is a link to a detailed description of this process.
When you start the remote debug configuration Eclipse will attach to the JBoss process. If successful the debug view will show the JBoss threads. There is also a disconnect icon in the toolbar/menu to stop remote debugging.
Define a new server/runtime in MyEclipse, for your JBoss 4 installation. Deploy your project to the defined server and start it in debugging mode.
For more information, go to the MyEclipse learning center, also here.
For earlier releases, check in the inbuilt help.
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
I'm trying to initiate a remote debugging session on my PC with Eclipse & Tomcat.
I managed to run tomcat (not through eclipse) with the following params:
set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=5050
cataline jpda start
The server starts ok, this is the outcome:
Using CATALINA_BASE: "C:\Java\Tomcat"
Using CATALINA_HOME: "C:\Java\Tomcat"
Using CATALINA_TMPDIR: "C:\Java\Tomcat\temp"
Using JRE_HOME: "C:\Java\jdk1.6.0_27"
Using CLASSPATH: ...
Listening for transport dt_socket at address: 5050
...
...
INFO: Server startup in 12502 ms
Now, I opened eclipse, and loaded the relevant project.
I set a new debugging configuration using Remote Java Application with localhost and the right port. however when I run it, I get this error message:
Failed to connect to remote VM. Connection refused.
Connection refused: connect
Can't really understand where is the problem. this is all local inside the PC, so there shouldn't be any firewalls involved, can someone think of something ?
Found the solution. apparently the connection was made, but Eclipse & Tomcat don'tt show any notification or status regarding it.
Then, when you initiate the connection again, you get the error because you're already connected.
I think that a small notice, either from Eclipse, or from Tomcat would be nice.
Try adding the following debug options directly to the JVM startup by directly modifying the catalina startup script
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5050
There could be problems when there are code mismatches between eclipse and tomcat. So when it matches the error will disappear
You can configure it in remote java application section in debug configuration.
For more details you can refer this link