Debugging a webapp deployed on WSO2 Application Server with Eclipse

Debugging a webapp deployed on the WSO2 Application Server can be tiresome at times. The best possible way to achieve this is by remote debugging. Remote debugging is used to debug an application running on a remote server through a local development environment. This is done by starting the application on debug mode then attaching the local development environment to the debug port of the application. This example uses Eclipse for the debugging but this can be done similarly with Intellij Idea as well.

Deploy the webapp on the WSO2 Application Server, then stop the server. In this example an Application Server running on localhost is used.

Step 1: Set up Debug Configurations

  1. Import the webapp into Eclipse.
  2. Place breakpoints where needed.
  3. In Eclipse, go to Run -> Debug Configurations. 
  4. Select Remote Java Application from the left pane then click on the New icon on top.
  5. Select the newly created Debug Configuration, then change the configuration as follows.
  6. Click on the Browse button then select the project that needs to be debugged.
  7. Input the Host and Port of the Application Server. Here we shall be using localhost and 8000 as the port.

The configuration is given below.

Screenshot from 2016-01-05 18-53-01

Step 2: Start the Application Server in Debug Mode

Navigate to <AS_home>/bin from the terminal then start the Application Server on debug mode with the following command.

./wso2server.sh –debug 8000

Here 8000 is the debug port and should be the same as the port given in the debug configuration in Eclipse.

When the server starts listening to the address, start debugging.

Do drop a comment if you have any issues. Have fun!