Remote Debugging in WSO2 Identity Server

Nuwan Harshakumara Piyarathna
4 min readMar 6, 2022
Source : https://blogs.sap.com/2020/05/07/advanced-debugging-of-mta-based-apps/

Hi folks.In this tutorial , I am going to show you how to do remote debugging on the WSO2 identity server. Let’s start !

Prerequisites

  • IntelliJ IDEA as IDE
  • Download and unzip the latest version of WSO2 Identity Server from here.
  • Download the WSO2 Identity Server codebase in which you want to try remote debugging. (Here , I am going to use carbon-identity-framework as the code base.)

Set up the Debugger

Open the WSO2 Identity server codebase using IntelliJ IDEA IDE.Go to Run -> Edit Configurations .Then the Run / Debug configurations menu will pop up.Click the (+) icon of the top left corner.

Now list of new Configuration options will appear.Scroll down and select Remote JVM Debug.

Note : If you’re using an older version of IntelliJ IDEA look for the Remote option.Then follow the rest of the steps.

Now you can give a name to your debugger.Keep the rest of the settings as it is and press OK.

Now you have successfully created a debugger.

Run the Debugger

Go to Run -> Debug and select your Debugger.In my case , I created a Debugger named “My Debugger” and I selected it.

Now your Debugger has started.Debugger Console will show a message like below.

Add the breakpoints to the code

Choose the Code segment that you want to debug and click the left side of the code to add breakpoints as shown in the below image.

Start the Identity Server in debug mode

Go into the unzipped WSO2 Identity Server folder and let’s call it <IS_HOME>.Navigate to <IS_HOME>/bin and start the server in debug mode using following commands.

  • On Windows : wso2server.bat debug 5005
  • On Linux/Mac OS : sh wso2server.sh debug 5005

Try it…

For the demonstration , I am going to use WSO2 Identity Server version 5.11.0.You can download it from here.For the code for remote debugging , I am going to use carbon-identity-framework which is a main component of wso2 identity server.First , we have to find the relevant carbon-identity-framework version.Go to https://github.com/wso2/product-is and search for v5.11.0 in the tags.

Open pom.xml file.Press Ctrl+F (on Windows/Linux) and Cmd+F (in Mac) to search a text.Now search for “carbon-identity-framework.version>”.

We need to checkout the carbon-identity-framework version v5.18.187 and debug it.

Open a terminal and use the below commands to clone the project and checkout to the tag.

git clone https://github.com/wso2/carbon-identity-framework.gitcd carbon-identity-frameworkgit checkout v5.18.187

Now open the project using IntelliJ IDEA IDE.Create a new Debugger as mentioned above.

Press Ctrl+Shift+N (Windows/Linux)or Cmd+Shift+N (Mac) to search a file and type “DefaultStepBasedSequenceHandler” and go to DefaultStepBasedSequenceHandler.java class file.I have put a breakpoint like in below line.

Start the WSO2 Identity Server .Run the Debugger.

After WSO2 identity Server is started, go to https://localhost:9443/console .Then the breakpoint will hit.

Press F9 to resume the program and Enter username and password as “admin” and click Continue.Then the breakpoint will hit again.

When running the functionality related to the code that you added the breakpoints, the program will suspend at the breakpoint.Then you can perform any debugging actions like stepping, expression evaluation, and so on.

Note : Even Though I used WSO2 Identity Server for the demonstration, we can try remote debugging on any WSO2 product by following the same steps.

Hope you have finished the tutorial successfully.Let’s meet from another tutorial.

Happy coding !!!

--

--

Nuwan Harshakumara Piyarathna

Software Engineer Intern at WSO2 | Computer Engineering Undergraduate of University of Peradeniya | https://nuwan.me