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

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.

Related

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)

Intellij Idea Remote ignores breakpoints inside Spring components code

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.

Setting up environment for debugging - Intellij Tomcat Maven

I've been attempting to set up a remote debug configuration in IntelliJ.
The application itself is deployed via tomcat7 plug on the command line and works as expected.
Now I would like to debug this application and am unsure how to connect a remote debugger in this case.
I have edited tomcat startup.bat
set JDPA_ADDRESS=8080 set JDPA_TRANSPORT=dt_socket
and set up a remote config in IntelliJ
When the debugger configuration gets run, "handshake failed" error appears.
Port 8080 is usually a HTTP port used by Tomcat, your debugger port must be different.

Not able to start Weblogic services

I am using Weblogic 11g, and JDK version - jdk1.8.0_60.
I created a domain successfully with a managed server and installed windows services for my application. But when I start my windows services it gives the below error message
I am able to start the services from the command prompt by running these batch files : startWebLogic.cmd and startManagedWebLogic.cmd for AdminServer and ManagedServer respectively.
I have not found any sort of errors in log files and also in the event viewer.

Can't debug tomcat application with gradle tomcat plugin

According to home page of gradle tomcat plugin FAQ section:
How do I remote debug my Tomcat started up by the plugin?
I need to add the following environment property:
GRADLE_OPTS = -Xdebug Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
During run of container I should see information that it listens on particular port: Listening for transport dt_socket at address: 5005, but in my case it's not working.
How I can configure it properly ? I'm running intellij idea 14.1 Ultimate.
In my case it worked as I started the Tomcat in the IDE itself and not the CLI.
For that I created two run/debug configurations, one for Tomcat and one to Remote connect the debugger to the Tomcat process.
For the Remote configuration, use the port 5005 like mentioned in the plugin FAQ debug section.
For the Tomcat configuration, you have to set the JVM settings explicitly. Simply put -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 as a value into the JVM options textfield in the Gradle run/debug config.
After both configurations have been created and properly configured, first run the Tomcat process and then connect to it by debugging the Remote configuration.
You can find an entire spring-mvc example and an detailed solution here.

Categories

Resources