Intellij Idea Remote ignores breakpoints inside Spring components code - java

I'm trying to debug a spring-boot application with Intellij Idea's Remote debugger.
I run my app locally on my development machine with Intellij Idea "Spring Boot" run configuration, with the following VM options configured in run configuration:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
I have no other java apps running.
Then I run another Intellij Idea run configuration "Remote Debugger". It has the following config:
host: localhost; port:5005, debugger mode: Attach to remote JVM
I can see the following message in console:
Connected to the target VM, address: 'localhost:5005', transport: 'socket'.
But the breakpoints in controller classes and other components are ignored.
BUT!!! If i select my Spring Boot run configuration and simply run it in debug mode (so that there is no need for running a separate Remote Debugger run config) breakpoints work as expected.

Be sure the code is executed within the VM you are going to debug. Check this e.g. with logging.
Example:
You have to hit a REST endpoint. Doing this with your browser or a REST client will halt the VM at the configured breakpoint as expected. Doing this running a SpringBootTest will execute the code in its own VM, mocking the webserver or starting a new webserver on a different (probably arbitrary) port.

Related

Cannot connect to the remote server via Intellij for debug

I have a remote Linux server and an application on it which I need to debug. I start the .jar file through the terminal in Intellij with line:
sudo java -Dspring.profiles.active=test -Dspring.config.additional-location=file:/.../external.properties -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar /.../JARFILE.jar
Jar file is started correctly, the application is working, but I cannot debug it remotely via IDEA with those settings: remote debugging configuration.
It throws an error saying "java.net.ConnectException: Connection timed out: connect." after a few seconds from I clicked the debug button.
What should I do?
You say that you are unable to connect to the JVM via a debugger.
I'd expect that the reason for this error is the fact that you are not launching the JVM with the correct input arguments so that it can run in debug mode.
The easiest fix for this issue would be to allow IntelliJ to run it for you with correct configuration.
You say that you want to deploy the app to a remote server and debug it from there. Why not use this functionality in IntelliJ, which will guarantee that correct flags are set.
I think this value address=*:5005 might be wrong, try running it with address=5005

What is the most efficient/automated way to remote debug a SOA application running on Linux VM from Windows desktop through IntelliJ IDEA?

enter image description here
I want to build and remote debug an SOA based CDI java application running on a Linux VM from Windows desktop using IntelliJ Idea. What is the most efficient way to do this so that it relieves me from manually transferring (sftp) the application, set up for remote debugging, etc?
I don't want to exit my IDE but would like to debug the application on a remote machine by modifying the app repeatedly. I would like to see the results in the IDE console window/web browser as applicable.
I used the remote debugging option in Intellij IDE, In run/debug configuration option I used Listen to remote JVM and start the debug in IntellijIDE.
I then run the following command in VM Linux:
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 com.intel.podm.rest.RequestValidationFilter
In Intellij IDE the command line arguments are dynamically updating to
-agentlib:jdwp=transport=dt_socket,server=n,address=DESKTOP-52V2CBR:5005,suspend=y,onthrow=,onuncaught=
This is fixed by opening SSH on Linux and remote debug in Intellij,and port number changes in standalone.sh script as project is based on wildfly server builded in gradle build environment.
Step 1: open a remote debug
step 2: ssh targetMachine#10.10.10.10 –L 8888:127.0.0.1:8787
If your application is in different machine try to create SSH tunnel for example:
ssh targetMachine#10.10.10.10 –L 8888:127.0.0.1:8787
Where targetMachine#10.10.10.10 is target user and address.
8888 is the local port where is IDE
8787 is debbuger port in the targetMachine (you can check that port in standalone.sh script)

Unable to run WebLogic Server in debug mode in Eclipse

I am not trying to do any remote debugging in Eclipse. I am just trying to run WebLogic Server (which is in Eclipse) in DEBUG mode. I am getting a strange error message, which is shown in the attached image. The server is not starting from Eclipse when I try after this option. I am using Java 1.6
Do below setting to start debugger, it works fine in my case:
Edit /bin/setDomainEnv.sh file and add this on top:
JAVA_OPTIONS="$JAVA_OPTIONS -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
The suspend=y will start your server and wait for you to connect with IDE before continue.
If you don't want this, then set to suspend=n instead.
Start/restart your WLS with /bin/startWebLogic.sh
Once WLS is running, you may connect to it using Eclipse IDE.
Go to Menu: Run > Debug Configuration ... > Remote Java Application and create a new entry.
Ensure your port number is matching to what you used above.

How to debug remote deployed spring boot app & maven on eclipse

I've deployed application on provider server on URL:
http://my.domain.net/my-spring-boot-app/
Provider use Tomcat as java app container. App connects to PostgreSQL, and it can do this only from this server host - because it is a restriction (probably on pg_conf). That it's important, because an error shows only on server site. How can I debug remotely my Spring Boot (war!) application, when I use maven & eclipse pack?
I don't know about the PostgreSQL issue but seems to me that this has nothing to do with data access layer or tools as it is basically a Java application which implies the rules for all JVM applications.
So in order to set up your server for remote debug, you have to hack the jvm (catalina in your case as you are running a Tomcat server) startup options by adding below entry to your startup script:
For a Windows system:
set CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n %CATALINA_OPTS%"
For a *nix system:
export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n $CATALINA_OPTS"
There is a shortcut to the below instruction, using the catalina startup script options, if that represents an alternative for you: catalina jpda start
You application is then up and listening on the configured port (8787 is this sample, which you must be open), and you can then attach your IDE (Eclipse) to debug the application remotely:
Navigate to Run -> Debug Configurations
Create a new Remote Java Application configuration
In the Connect tab setup the run configurations including the Host and Port
From the Common tab, check the Debug option.
Apply and Run you configuration.

Eclipse WebLogic debugging

I know you can debug by just clicking the debug icon in Eclipse. Is it possible to start WebLogic from the command line with debugging and still debug? When I do that, in Eclipse under server I see that the status is "Started", not "Debugging". Can this only be done by setting up remote debugging?
You need to add parameters to the JAVA_OPTIONS in the startWebLogic.cmd (or startWebLogic.sh):
-Xrunjdwp:transport=dt_socket,server=y,address=1044,suspend=n -Xdebug
Then, in Eclipse you have to use remote debugging indeed.
Add a new Remote Java Application in the Debug Configurations (via the menu: Run - Debug Configurations).
Make sure the correct project is selected (Browse button) and fill in localhost in Host and 1044 in Port. The other options you can leave unchanged.
If you click debug you should be able to see your remote WebLogic running in the Debug perspective.
If you see a WebLogic started under Servers, you are looking at an embedded server and not at the one you started via the command line. Make sure to stop any embedded server before starting via the command line as they will not be able to run on the same port together anyway.

Categories

Resources