CONTROLLED DATA
Leidos Proprietary - US Citizens ONLY
The information contained herein is proprietary to Leidos, Inc. It may not be used, reproduced, disclosed, or exported without the written approval of Leidos.

Note:  This article was authored by Unknown User (singhs8)

Step-by-step guide

To debug a REST service in Eclipse using Maven, use the following steps. 

Steps

Build your service on the command-line and run a remote Java application configuration in Eclipse using the following steps:

  1. Build your REST service on the command line using the following command in the main folder:

           mvn clean install

  2. Start the service on the command line using the following command:

     java -Dspring.profiles.active=local -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -jar flagging-service-1.0.0-SNAPSHOT.jar

            The different parameters are:

                spring.profiles.active: The profile you are using to run your service
                -Xdebug: Indicates that the service is to be run in the debug mode
                -Xrunjdwp: Indicates that the connection between the application and the debugging application (Eclipse) will be via the Java Debug Wire Protocol
                transport=dt_socket: Indicates that the application and the debugger will communicate using the socket protocol
                server=y: Indicates that the Java Virtual Machine will act as a server for the debugging and the debugger itself will have to connect to it as a client
                suspend=n: Specifies if the process should be suspended until the debugger attached to it. If this is set to 'y', it will wait until it receives a connection request from the debugger.
                address: The port on which the debugger should connect

  3. In Eclipse, connect to this service using a "Remote Java Application" as a "Debug Configuration". 


             For the remote configuration, use the following values to set it up:

             Host: The URL of the Spring Boot REST service
              Port: The "address" used for the port in step 2 when starting the service. 

  4. Set breakpoints in the application in Eclipse - using the same code base that was used to start the service above. 
  5. Send requests to the service using a tool like Postman or Katalon. 
  6. The breakpoints will be activated.