<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tharika Madurapperuma on Medium]]></title>
        <description><![CDATA[Stories by Tharika Madurapperuma on Medium]]></description>
        <link>https://medium.com/@tharika?source=rss-e10a48267e46------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KVgSLq5hyZFvy_RFVzxh6A.jpeg</url>
            <title>Stories by Tharika Madurapperuma on Medium</title>
            <link>https://medium.com/@tharika?source=rss-e10a48267e46------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 18:31:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tharika/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deploying a Self-Hosted Gateway with WSO2 API Platform]]></title>
            <link>https://tharika.medium.com/deploying-a-self-hosted-gateway-with-wso2-api-platform-8c09e8d20669?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c09e8d20669</guid>
            <category><![CDATA[wso2-api-platform]]></category>
            <category><![CDATA[self-hosted-api-gateway]]></category>
            <category><![CDATA[centralized-governance]]></category>
            <category><![CDATA[private-gateway]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Wed, 13 May 2026 06:22:32 GMT</pubDate>
            <atom:updated>2026-05-13T06:22:32.600Z</atom:updated>
            <content:encoded><![CDATA[<h4>Deploy and manage API gateways inside your private network with centralized cloud governance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Az_LlN9WctfMG1c9Gn_NGQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@creativemindsfactory?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Creative Minds Factory</a> on <a href="https://unsplash.com/photos/a-stylized-illustration-of-data-storage-and-processing-YLzJtu-Vmmo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Most organizations today aspire to achieve centralized API governance through SaaS solutions. However, some organizations must keep API traffic within private networks due to security and compliance requirements. As a result, these organizations are often forced to choose between adopting a fully cloud-hosted gateway solution with limited traffic isolation, or maintaining a fully self-managed API infrastructure. Isn’t there a better solution for this?</p><h3>WSO2 API Platform’s Self-Hosted Gateway</h3><p>There is a solution. Now you can easily achieve a SaaS control plane with a self-hosted data plane using the Self-Hosted Gateway solution of <a href="https://wso2.com/api-platform/">WSO2 API Platform</a>.</p><h4>Key Benefits?</h4><ul><li>API Traffic remains local to your network</li><li>Lower latency</li><li>Better compliance</li><li>Centralized Governance</li></ul><h4>Why a self-hosted gateway instead of a fully managed gateway?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*npkSg9mR4DiFK6ddc5uBUA.png" /><figcaption>Fully Managed gateway vs Self-Hosted gateway</figcaption></figure><h3>Getting started with WSO2 API Platform’s Self-Hosted Gateway</h3><h4>Step 1: Setting up a self-hosted gateway locally</h4><ol><li>Login to the API Platform Console — <a href="https://console.bijira.dev/">https://console.bijira.dev/</a></li><li>Access the left menu within your organization and go to <strong><em>Admin</em></strong> → <strong><em>Gateways</em></strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oAVrSUDVsmj7XaBny7MNfw.png" /><figcaption>Go to Admin → Gateways from the left menu within your organization</figcaption></figure><p>3. Click on <strong>“<em>Add Self-Hosted Gateway”</em> </strong>Button and specify metadata for your self-hosted gateway as shown below.</p><ul><li>Under General Details Select <strong>API Gateway</strong> as the <em>Type</em>. This is already selected by default.</li><li><em>Name</em> — Self-Hosted-Gateway-1</li><li><em>Description</em> — This is a self-hosted gateway running in <a href="https://localhost:8443/">https://localhost:8443</a></li><li>Let’s keep the other values as provided by default. The <em>URL</em> can be changed if you need to change where your gateway is running. In this article, we are going to deploy this gateway locally.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MjLPTWZP6sLgAjDM1tGZfA.png" /><figcaption>Provide metadata for your self-hosted gateway</figcaption></figure><p>4. You will see that the gateway status is indicated as <em>inactive</em> as it is still not running locally in your machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9VTIYWTLGva6Ou4tYUuj_Q.png" /><figcaption>Gateway status is indicated as inactive</figcaption></figure><p>5. If you scroll down, you will find the instructions and commands required to run the gateway locally. Execute the commands in the specified order in the <strong><em>“Quick Start”</em></strong> tab, and ensure that all prerequisites are installed and available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0RDvGBDnrY0qNE4hIaG7g.png" /><figcaption>Run the commands in order</figcaption></figure><p>6. Now your gateway status will be indicated as active as shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkeI4dloGuZuWpGG_HtTZw.png" /><figcaption>Gateway is in the active state</figcaption></figure><h4>Step 2: Creating and deploying an API in your self-hosted gateway</h4><ol><li>Create a new project in your organization to hold the APIs that will be deployed in the self-hosted gateway.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aEL03Y37d7Fj0kLtdNmSXw.png" /><figcaption>Create new project</figcaption></figure><p>2. Provide the project details as shown in the image below and click on <strong>“<em>Create”</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mO2Nc93qU1LTBu0k_kdLdw.png" /><figcaption>Provide details for project creation</figcaption></figure><p>3. Select <strong><em>“Import API Contract” </em></strong>option<strong><em> </em></strong>under ingress APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RLuwDlsM_-UOmVsY_jjtjg.png" /><figcaption>Import API Contract</figcaption></figure><p>4. Let’s use the <a href="https://petstore3.swagger.io/api/v3/openapi.json"><strong>Swagger Petstore API</strong> <strong>Contract</strong></a> to create the API Proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-zaomwi4TmfQUJVLfwoXug.png" /><figcaption>Importing swagger petstore API contract</figcaption></figure><p>5. Then click on <strong><em>“Next”</em></strong>. Now provide the required metadata for the API and click on <strong><em>“Create”</em></strong>. Make sure the <em>self-hosted gateway</em> option is selected when creating the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Dbgy5YunQXc4v3IUjLAkQ.png" /><figcaption>Provide API metadata</figcaption></figure><p>6. Once created, you will see the API being deployed in your locally running self-hosted gateway if you observe the logs.</p><h4><strong>Step 3: Apply policies to the API</strong></h4><ol><li>Now it’s time to apply polices to the created API as we would need some sort of control and governance over the it. Go to <strong><em>Develop → Policies</em></strong> in the left menu under the API view. There is a list of policies that you can select from as shown in the image below.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJlHRceqKH0Oda4dzAIBWQ.png" /><figcaption>Available policies to select from</figcaption></figure><p>2. Let’s select the <strong><em>“Rate Limit — Basic”</em></strong> policy from the available policy list and drag and drop it under <strong>Global policies</strong> for the API. This will apply a rate limit of <em>5 requests per minute</em> for all available resources of the Swagger Petstore API. Then <strong>save</strong> the API once the policy is added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UbSe_Qfb1PnfYxOWdkpScw.png" /><figcaption>Apply Rate Limit — Basic policy under Global Policies</figcaption></figure><p>3. Re-deploy the API for the policy changes to take effect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UY6rNQX_zBkn65cDDYPbSw.png" /><figcaption>Re-deploy the API</figcaption></figure><h4>Step 4: Invoke the API</h4><ol><li>To invoke the API, go to <strong><em>Test → cURL</em></strong> in the left side menu.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E_V3HAede0YKYnpL8Ceejg.png" /><figcaption>Test the API</figcaption></figure><p>2. Select the resource that you want to invoke. Then provide the required parameters and copy the generated curl command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NxaDDUNfJLL1IySbCzycoA.png" /><figcaption>Copy the curl command</figcaption></figure><p>3. Invoke the API more than 5 times to see if the policy we have configured takes effect. You will see a response as below indicating that the rate limit has exceeded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ykHDVTIIqse8ms2WgA1JSg.png" /><figcaption>Rate limiting the API after 6 requests within 1 minute</figcaption></figure><p>Congratulations! You have successfully configured a self-hosted gateway with <a href="https://wso2.com/api-platform/">WSO2 API Platform</a>. With centralized governance via the SaaS control plane, you have deployed an API in your self-hosted gateway, configured a rate limiting policy and invoked the API successfully.</p><p>You can explore more capabilities by following our official API Platform documentation <a href="https://wso2.com/api-platform/docs/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c09e8d20669" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to run scenario tests in WSO2 API Manager?]]></title>
            <link>https://tharika.medium.com/how-to-run-scenario-tests-in-wso2-api-manager-bcbab7f5a04f?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcbab7f5a04f</guid>
            <category><![CDATA[test]]></category>
            <category><![CDATA[senario]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[wso2developercorner]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Sat, 03 Jul 2021 09:17:36 GMT</pubDate>
            <atom:updated>2021-07-03T09:17:36.496Z</atom:updated>
            <content:encoded><![CDATA[<p>Is my product pack working fine in a real scenario?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kSw-njRsFwVlqbTElIX8oQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@ikukevk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kevin Ku</a> on <a href="https://unsplash.com/s/photos/scenario-test-computer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Scenario tests are where we test an <strong>actual local deployment</strong> of the product. You can simply start a server in your <strong>local machine</strong> and run the scenario test cases from the repository and verify if a complete scenario or a use case works fine with that particular deployment.</p><p>Instead of writing a lot in this post, let me keep it short and simple. 🙂</p><p>→ Repository containing scenario tests : <a href="https://github.com/wso2/product-apim"><strong>product-apim</strong></a></p><p>→ Branches containing scenario tests :</p><p>As in the following image, there is a scenario test branch for each product version starting from API Manager 3.0.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LixP-xJVcB1blHcm0wEjiA.png" /><figcaption>Branches containing scenario tests</figcaption></figure><h4>Step 1 : Pick the branch of your choice from the above</h4><h4>Step 2 : Build the following modules of the repo without tests</h4><ol><li>Move in to <strong><em>&lt;product-apim&gt;/modules/integration/tests-common</em></strong> module and build it using the following command, once without tests.</li></ol><blockquote>mvn clean install -Dmaven.test.skip=true</blockquote><p>2. Now move into <strong><em>&lt;product-apim&gt;/product-scenarios/scenarios-common </em></strong>module and build it once without tests.</p><blockquote>mvn clean install -Dmaven.test.skip=true</blockquote><p>3. Then open the <strong><em>&lt;product-apim&gt;/product-scenarios/pom.xml </em></strong>file and comment out the scenarios-common module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hT7eWzj6XuH0uSrCHpBkow.png" /><figcaption>Comment out the scenarios-common module</figcaption></figure><p>4. Move into <strong><em>&lt;product-apim&gt;/product-scenarios</em></strong> module and build it without tests once.</p><blockquote>mvn clean install -Dmaven.test.skip=true</blockquote><h4>Step 3 : Download, setup and start the product pack</h4><p><a href="https://wso2.com/api-manager">Download</a> the relevant product version. You can even use a <a href="https://wso2.com/updates/wum">WUM</a> updated pack.</p><p>Now you can set up your pack with your preferred configurations, for example configure the pack with MySQL DB. Then start the server.</p><p><strong>Step 4 : Run the tests</strong></p><p>Go into <strong>product-scenarios</strong> module and run the following command</p><blockquote>mvn clean install</blockquote><p>This will run all the available scenario tests on your running deployment.</p><p>You can run a specific scenario test by going into the respective module and executing a <strong><em>mvn clean install</em></strong>. Use the relevant <strong><em>testng.xml</em></strong> file inside the folder, for example <a href="https://github.com/wso2/product-apim/blob/product-scenarios-4.0.0/product-scenarios/1-manage-public-partner-private-apis/1.1-expose-service-as-rest-api/1.1.1-create-rest-api-from-scratch/src/test/resources/testng.xml">this</a>, to manage the tests that are run.</p><p><strong>Bonus Tip : </strong>😇</p><p>You can even <strong>debug</strong> the test cases by adding a debug configuration to your IDE. Use the normal process of debugging test cases. You can use the command below.</p><blockquote>mvn clean install -Dmaven.surefire.debug</blockquote><p>Thank you for reading the article!</p><p>If you find any outdated content or issues with this article, please feel free to create an issue at <strong>Developer Corner</strong> Git repository <a href="https://github.com/tharikaGitHub/developer-corner">here</a>. Let’s grow together and help others in their journey too!</p><p>If you like this article please give it a clap. 🙂</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcbab7f5a04f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to debug Integration Tests in WSO2 API Manager Code?]]></title>
            <link>https://tharika.medium.com/how-to-debug-integration-tests-in-wso2-api-manager-code-579bc18638e5?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/579bc18638e5</guid>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[integration-testing]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[wso2developercorner]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Sat, 22 May 2021 12:10:21 GMT</pubDate>
            <atom:updated>2026-01-07T07:09:13.236Z</atom:updated>
            <content:encoded><![CDATA[<p>After my changes some Integration Tests are failing! How can I find where the problem is? — Is this you? Then this article is for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U2doBF3eEw_mHMbeJBpuQg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@codestorm?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Safar Safarov</a> on <a href="https://unsplash.com/s/photos/computer-code?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>You might get the requirement to debug <strong>Integration tests</strong> in WSO2 API Manager code after writing a test yourself in <a href="https://github.com/wso2/product-apim"><strong>product-apim</strong></a> repository or else if a change done by you to <a href="https://github.com/wso2/carbon-apimgt"><strong>carbon-apimgt</strong></a> repository causes a build failure.</p><p>Let’s see how this can be done easily.</p><h3>Step 1 : Build the product-apim repo without tests.</h3><p>Build the WSO2 API Manager distribution as described in the section titled <em>“How to quickly build a latest WSO2 API Manager pack (distribution) and start the server locally?”</em>, in article <a href="https://tharika.medium.com/how-to-contribute-to-wso2-api-manager-65d96fa9665c"><strong>“How to contribute to WSO2 API Manager?”</strong></a> <strong>by skipping the tests. </strong>Make sure your changes are included when you are building the repositories.</p><h3><strong>Step 2 :</strong> <strong>Find the test case that you need to debug</strong></h3><p>In the <strong>product-apim</strong> repository’s <a href="https://github.com/wso2/product-apim/tree/master/all-in-one-apim/modules/integration/tests-integration/tests-backend"><strong>tests-backend module</strong></a>, you will be able to find the Integration tests for WSO2 API Manager.</p><p>Assume that the test you need to debug is, <a href="https://github.com/wso2/product-apim/blob/master/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APITagVisibilityByRoleTestCase.java">APITagVisibilityByRoleTestCase</a>. Open it up in your IDE (IntelliJ IDEA for example) and place <strong>breakpoints</strong> at the specific line numbers that you need to stop and analyze during debugging.</p><h3>Step 3 : Comment out the rest of the test cases that are not needed</h3><p>If you want to run only your selected test case, (this is the situation most of the time), <strong>comment out</strong> the other test cases in <a href="https://github.com/wso2/product-apim/blob/master/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml"><strong>testng.xml</strong></a> leaving the <a href="https://github.com/wso2/product-apim/blob/master/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APITagVisibilityByRoleTestCase.java">APITagVisibilityByRoleTestCase</a> related entry as it is.</p><h3><strong>Step 4 : Configure the debugger configurations in your IDE to listen in port 5005 for product-apim</strong></h3><p>Now configure the <strong>remote debugger configurations</strong> in your IDE to listen in port 5005 which is the default.</p><h3>Step 5 : Add debug command to automation.xml</h3><p>In order to debug the <a href="https://github.com/wso2/carbon-apimgt"><strong>carbon-apimgt</strong></a> code while running the Integration test, you must specify the debug command at the place where the carbon server is running when executing the Integration tests.</p><p>This can be done by adding the debug option as a command line argument in <a href="https://github.com/wso2/product-apim/blob/master/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/automation.xml"><strong>automation.xml</strong></a> file in <strong>product-apim</strong> repository.</p><p>For this, find and uncomment the following property in it.</p><blockquote><strong>&lt;parameter name=”cmdArg” value=”debug 5005&quot;/&gt;</strong></blockquote><p>And then, most importantly change the port to <strong><em>5006</em></strong> because as you remember, the <em>product-apim</em> repository is configured to connect with port 5005 during the debugging session. Then the property will look like below.</p><blockquote><strong>&lt;parameter name=”cmdArg” value=”debug 5006&quot;/&gt;</strong></blockquote><h3>Step 6 : Configure the debugger configurations in your IDE to listen in port 5006 for carbon-apimgt</h3><p>Now open a different IDE window with <em>carbon-apimgt</em> code and configure a remote debugger configuration for port <strong>5006</strong>.</p><h3>Step 7 : Place breakpoints in carbon-apimgt code</h3><p>If you want to debug specific code from <em>carbon-apimgt</em> that gets executed while running the integration tests, place <strong>breakpoints</strong> at the respective places in your IDE.</p><h3>Step 8 : Run the Integration tests in debug mode</h3><p>Now we can start running the Integration test. For this, navigate in to <strong><em>&lt;repo-root&gt;/all-in-one-apim/modules/integration/tests-integration/tests-backend</em></strong> directory by using your terminal or command line.</p><p>Then execute the following command.</p><blockquote><strong>mvn clean install -Dmaven.surefire.debug</strong></blockquote><p>This will compile the code and show that it is listening for port 5005 when the testing phase has started to run as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MUDzoo5s6hpLqjxUai-Ugg.png" /><figcaption>Listening for port 5005</figcaption></figure><p>This is the time that you need to connect the IDE containing <em>product-apim</em> to this port <strong>5005</strong>.</p><p>After it is connected, you will see the following screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G4sXaq5AE1j2Yj51JR_SVA.png" /><figcaption>Will be listening for port 5006</figcaption></figure><p>If the build seem to be stuck at this point for about 10 seconds, keep connecting the IDE containing <em>carbon-apimgt</em> to port <strong>5006</strong>. After seeing a message as <strong>connected</strong> in the IDE, the tests will eventually start running.</p><h3>⚠️ <strong>Special Case : Please keep an eye on this </strong>👀👇🏼</h3><p>Once the tests start to run, <strong>please keep an eye</strong> on the <strong>Connected</strong> status shown in the debug window in your IDE containing the <strong>carbon-apimgt</strong>. If you see it as disconnected, connect the IDE back to 5006 port. This happens because the carbon server can restart from one test group to another, so you need to <strong>reconnect</strong> the port as we have given that number as a command line argument in <strong>automation.xml</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lRtz5kT5-VaByP0wYZSzng.png" /><figcaption>Port 5006 disconnected</figcaption></figure><p>Okay Great! Now we have actually done everything needed to configure the setup for debugging the code, both the Integration test and the <em>carbon-apimgt</em> code at the same time. You can continue your debugging and identify the culprit for the failing test case with ease. 🙂</p><p>Happy Debugging!</p><p>Thank you for reading the article!</p><p>If you find any outdated content or issues with this article, please feel free to create an issue at <strong>Developer Corner</strong> Git repository <a href="https://github.com/tharikaGitHub/developer-corner">here</a>. Let’s grow together and help others in their journey too!</p><p>If you like this article please give it a clap. 🙂</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=579bc18638e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to debug Unit Tests in WSO2 Code?]]></title>
            <link>https://tharika.medium.com/how-to-debug-unit-tests-in-wso2-code-c033786d71e2?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/c033786d71e2</guid>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[wso2developercorner]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Sat, 06 Feb 2021 07:38:39 GMT</pubDate>
            <atom:updated>2021-02-06T07:38:39.782Z</atom:updated>
            <content:encoded><![CDATA[<p>Some unit tests are failing after my changes! How can I debug the unit test I wrote to see if it is working fine? — Is this you? Then this article is for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S4Q6750FfBwJzPLAZ2Qusw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@riku?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Riku Lu</a> on <a href="https://unsplash.com/s/photos/code-testing?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>After writing a unit test, you almost always get the requirement to debug the test case that you wrote. Or else if you encounter a build failure due to a failing unit test, you need to always debug and find what went wrong.</p><p>In this article, I’m going to show you how.</p><p>In <a href="https://wso2.com/api-management/">WSO2 API Manager</a> for example, unit tests can be found in <a href="https://github.com/wso2/carbon-apimgt">carbon-apimgt</a> repository. So when you run the following command, all unit tests will also be executed.</p><pre>mvn clean install</pre><h3><strong>Method 1 : Debugging the test case from the IDE</strong></h3><p>Unit tests in WSO2 API Manager uses <strong>JUnit</strong> as the framework. Hence you can do the debugging easily from the <strong>IDE</strong> you use. Most probably this might be IntelliJ IDEA.</p><p>This is the method that is commonly used by many developers for JUnit based test cases. You can refer the following article to try that out.</p><p><a href="https://www.jetbrains.com/help/idea/performing-tests.html">https://www.jetbrains.com/help/idea/performing-tests.html</a></p><p>But this never works for me when debugging unit tests for <strong>carbon-apimgt</strong> repository. 😂 This might be the same for you too. So let me tell you the method I use.</p><h3>Method 2 : Debugging by executing a mvn command</h3><p>Assume you need to debug a test case in package <a href="https://github.com/wso2/carbon-apimgt/tree/master/components/apimgt/org.wso2.carbon.apimgt.impl"><em>org.wso2.carbon.apimgt.impl</em></a><em> </em>Then execute the following steps to start debugging the unit tests in that package.</p><ul><li>Move into the relevant package root folder from the terminal. In our case this will be</li></ul><blockquote><strong>&lt;repository_root&gt;/components/apimgt/org.wso2.carbon.apimgt.impl</strong></blockquote><ul><li>Now execute the command below to start running the tests in debug mode.</li></ul><pre>mvn clean install -Dmaven.surefire.debug</pre><ul><li>You will now see the tests halted at the following line listening at port 5005.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ikB64x-ApWjZCO0fg9r4pw.png" /><figcaption>Tests listening at port 5005</figcaption></figure><ul><li>Now open your IDE and create a <strong>Debug Configuration</strong>. I am using IntelliJ IDEA here. Go to <strong>Run</strong> → <strong>Edit Configurations</strong>. Click on the <strong>+</strong> button in the window and select <strong>Remote</strong>. Add a new configuration as follows and click <strong>Apply</strong> → <strong>OK</strong>. Make sure the port is 5005.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QyzYBohO0uInZvGoRLGJbA.png" /><figcaption>NewDebugConfig</figcaption></figure><ul><li>Make sure to add <strong>breakpoints</strong> to the class that you want to debug in your IDE.</li><li>Click on the <strong>Debug</strong> icon in the toolbar after selecting the Debug Configuration you just created from the drop down menu.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-IUirucduosewwk9HRwBPw.png" /><figcaption>Click on Debug</figcaption></figure><ul><li>The tests will now start running and will hit the breakpoint you set up in your test class.</li><li>Now you can continue debugging the code as you like. 🙂</li></ul><p>Thank you for reading the article!</p><p>If you find any outdated content or issues with this article, please feel free to create an issue at <strong>Developer Corner</strong> Git repository <a href="https://github.com/tharikaGitHub/developer-corner">here</a>. Let’s grow together and help others in their journey too!</p><p>If you like this article please give it a clap. 🙂</p><p>Happy Debugging..!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c033786d71e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How and where to report an Issue in WSO2 API Manager?]]></title>
            <link>https://tharika.medium.com/how-and-where-to-report-an-issue-in-wso2-api-manager-6fb0f55a8ff?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fb0f55a8ff</guid>
            <category><![CDATA[report]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[wso2developercorner]]></category>
            <category><![CDATA[issues]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 10:20:16 GMT</pubDate>
            <atom:updated>2021-01-28T10:20:16.572Z</atom:updated>
            <content:encoded><![CDATA[<p>Faced an issue when using the product and want assistance or need to report the issue? Here is what you need to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzNUkFF5TObHOCWegbXc3w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kelly Sikkema</a> on <a href="https://unsplash.com/s/photos/problem?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>When developing the product, you might come across various issues related to an existing bug or a problem you can’t understand. Don’t worry. There are channels that you can take assistance from or report the issue which you think is a bug in the product.</p><h3>I found a Bug in the product! 😮</h3><p>For <a href="https://wso2.com/api-management/">WSO2 API Manager</a>, if you find a bug in the product, you have to report it in the <a href="https://github.com/wso2/product-apim"><strong>product-apim</strong></a> GitHub repository.</p><ol><li>Simply go <a href="https://github.com/wso2/product-apim/issues">here</a>.</li><li>Click on the <strong>New Issue </strong>button.</li><li>Fill in the details based on the template provided.</li></ol><p><strong>Note:</strong> Do not create issues in the <a href="https://github.com/wso2/carbon-apimgt"><strong>carbon-apimgt</strong></a> repository because the issues reported in <a href="https://github.com/wso2/product-apim">product-apim</a> are the ones that are given the priority.</p><h3>Where to report a Security Issue? 😎</h3><p>Security issues <strong>MUST</strong> be reported to <a href="/service/mailto:security@wso2.com">security@wso2.com</a> and not as a GitHub issue, in order to reach the proper audience. It is strongly advised to follow the <a href="https://docs.wso2.com/display/Security/WSO2+Security+Vulnerability+Reporting+Guidelines">WSO2 Security Vulnerability Reporting Guidelines</a> when reporting security issues.</p><h3>The product documentation is wrong! 😑</h3><p>All issues related to WSO2 API Manager <a href="https://apim.docs.wso2.com/en/latest/">documentation</a> should be reported in the <a href="https://github.com/wso2/docs-apim">docs-apim</a> GitHub repository. Simply create a new issue according to the template provided.</p><h3>I don’t know how to fix this! 😟</h3><p>While developing the product or while creating a solution using the product, if you face an issue that you can’t understand how to fix, you can always request assistance from our <strong>Developer Community </strong>in <a href="https://wso2-apim.slack.com/"><strong>Slack</strong></a>. They are actively getting involved in helping you out or directing you to the right place.</p><ol><li>Click on <a href="https://join.slack.com/t/wso2-apim/shared_invite/enQtNzEzMzk5Njc5MzM0LTgwODI3NmQ1MjI0ZDQyMGNmZGI4ZjdkZmI1ZWZmMjNkY2E0NmY3ZmExYjkxYThjNzNkOTU2NWJmYzM4YzZiOWU?src=sidebar">this link</a> to join the <strong>Slack</strong> community if you have not done already.</li><li>You can join the <strong>wso2-api-management</strong> channel for WSO2 API Manager specific detail and start asking questions or getting involved with others in the community by helping each other.</li></ol><p>If you find any outdated content or issues with this article, please feel free to create an issue at <strong>Developer Corner</strong> Git repository <a href="https://github.com/tharikaGitHub/developer-corner">here</a>. Let’s grow together and help others in their journey too!</p><p>If you like this article please give it a clap. 🙂</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fb0f55a8ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to contribute to WSO2 API Manager?]]></title>
            <link>https://tharika.medium.com/how-to-contribute-to-wso2-api-manager-65d96fa9665c?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/65d96fa9665c</guid>
            <category><![CDATA[wso2developercorner]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[contribution]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 10:19:29 GMT</pubDate>
            <atom:updated>2025-10-06T08:55:29.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZjgCT-olgKz95a12ByCCw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@domenicoloia?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Domenico Loia</a> on <a href="https://unsplash.com/s/photos/technology?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><a href="https://wso2.com/api-management/">WSO2 API Manager</a> is an <strong>Open Source Platform</strong> which anyone can contribute to. All community contributions are welcome.</p><p>WSO2 Developers carry out active development in the following repositories for WSO2 API Manager.</p><ol><li><a href="https://github.com/wso2/carbon-apimgt"><strong>carbon-apimgt</strong></a><strong> </strong>(branch — master) <strong>(Contains the backend code)</strong></li><li><a href="https://github.com/wso2/apim-apps"><strong>apim-apps</strong></a><strong> </strong>(branch — main) <strong>(Contains the UI code)</strong></li><li><a href="https://github.com/wso2/product-apim"><strong>product-apim</strong></a><strong> </strong>(branch — master) <strong>(Contains the code required to build the product pack)</strong></li></ol><h4>Pre-requisites</h4><ul><li>Java 11.</li><li>NodeJS 22.x.</li><li>Maven 3.x or higher.</li><li>Minimum memory 2GB.</li></ul><h3>How to quickly build a latest WSO2 API Manager pack (distribution) and start the server locally?</h3><ul><li>Checkout the code from <a href="https://github.com/wso2/product-apim">https://github.com/wso2/product-apim</a> master branch.</li><li>In the terminal, execute the following command to move to the <strong><em>all-in-one-apim</em></strong> folder inside <strong><em>product-apim</em></strong></li></ul><pre>cd all-in-one-apim</pre><ul><li>Then build the repository using the following command skipping the tests.</li></ul><pre>mvn clean install -Dmaven.test.skip=true</pre><ul><li>Obtain the WSO2 API Manager pack from <strong><em>&lt;product-apim&gt;/all-in-one-apim/modules/distribution/product/target</em></strong> directory and extract it to your desired location.</li></ul><blockquote>Example package name : wso2am-4.6.0-SNAPSHOT.zip</blockquote><ul><li>Start the WSO2 API Manager server by moving into <strong><em>&lt;APIM_HOME&gt;/bin </em></strong>folder where <strong><em>APIM_HOME</em></strong> is the folder you obtain by extracting the above zip and then execute the following command .</li></ul><p>If your machine is <strong>Linux</strong> or <strong>Mac</strong>,</p><pre>./api-manager.sh</pre><p>If your machine is <strong>Windows</strong>, execute the <em>api-manager.bat</em> file.</p><p>If you see <strong>a part of a log</strong> similar to the following in the Terminal / Command-line without any exceptions, you can safely assume that the server has successfully started.</p><blockquote>INFO — CarbonUIServiceComponent Mgt Console URL : <a href="https://localhost:9443/carbon/">https://localhost:9443/carbon/</a><br>INFO — CarbonUIServiceComponent API Developer Portal Default Context : <a href="https://localhost:9443/devportal">https://localhost:9443/devportal</a><br>INFO — CarbonUIServiceComponent API Publisher Default Context : <a href="https://localhost:9443/publisher">https://localhost:9443/publisher</a></blockquote><h3>What Portals can be accessed after server startup?</h3><ul><li><strong>Publisher</strong> <strong>Portal</strong> — <a href="https://localhost:9443/publisher">https://localhost:9443/publisher</a></li><li><strong>Developer Portal </strong>— <a href="https://localhost:9443/devportal">https://localhost:9443/devportal</a></li><li><strong>Admin Portal </strong>— <a href="https://localhost:9443/admin">https://localhost:9443/admin</a></li><li><strong>Management Console</strong> — <a href="https://localhost:9443/carbon">https://localhost:9443/carbon</a></li></ul><p>The functions defined in <a href="https://apim.docs.wso2.com/en/latest/get-started/apim-architecture/#api-publisher">this</a> document will be performed by the <strong>Publisher Portal</strong> while those defined in <a href="https://apim.docs.wso2.com/en/latest/get-started/apim-architecture/#api-developer-portal">this</a> document are performed by the <strong>Developer Portal</strong>. The <strong>Admin Portal</strong> and the <strong>Management Console</strong> are used for performing all the Administration related functions.</p><h3><strong>How to do changes locally to the repository and build the latest pack?</strong></h3><ul><li>Checkout the code from <a href="https://github.com/wso2/carbon-apimgt">https://github.com/wso2/carbon-apimgt</a> <em>master</em> branch.</li><li>Do the changes to the files as required.</li><li>Checkout the code from <a href="https://github.com/wso2/product-apim">https://github.com/wso2/product-apim</a> <em>master</em> branch if you have not already done so.</li></ul><p><strong>Note:</strong> Checkout both <strong><em>carbon-apimgt</em></strong> and <strong><em>product-apim</em></strong> to the same folder location.</p><p>After making your changes to the code in <a href="https://github.com/wso2/carbon-apimgt"><strong>carbon-apimgt</strong></a>, if you want to quickly make a complete pack with your changes included, follow the steps below.</p><ul><li>Navigate to <strong><em>carbon-apimgt</em></strong> folder and run the following command skipping the tests.</li></ul><pre>mvn clean install -Dmaven.test.skip=true</pre><ul><li>After the build is successful, navigate to <strong><em>product-apim/all-in-one-apim</em></strong> folder and open the <strong><em>/product-apim/all-in-one-apim/pom.xml</em></strong> file. Then change the following entry with the value found in <em>&lt;version&gt;…&lt;/version&gt;</em> element in the <strong><em>/carbon-apimgt/pom.xml</em></strong> file. For example with <strong>9.28.208-SNAPSHOT</strong>.</li></ul><pre>&lt;!-- APIM Component Version --&gt;<br> &lt;carbon.apimgt.version&gt;9.28.208-SNAPSHOT&lt;/carbon.apimgt.version&gt;</pre><ul><li>Now run the following command without tests from within the <strong><em>product-apim/all-in-one-apim</em></strong> folder.</li></ul><pre>mvn clean install -Dmaven.test.skip=true</pre><ul><li>Now you can obtain the WSO2 API Manager pack from <strong><em>&lt;product-apim&gt;/all-in-one-apim/modules/distribution/product/target</em></strong> directory and extract it to your desired location.</li></ul><blockquote>Example package name : wso2am-4.6.0-SNAPSHOT.zip</blockquote><ul><li>Extract and start the server and see whether your changes have been applied successfully.</li></ul><h4>Building the pack after doing UI changes</h4><p>In order to get the latest pack with the UI changes done on the <a href="https://github.com/wso2/apim-apps"><strong>apim-apps</strong></a> repo, you can do the following.</p><ul><li>Checkout the code from <a href="https://github.com/wso2/apim-apps">https://github.com/wso2/apim-apps</a> <em>main</em> branch.</li><li>Do the changes to the files as required.</li><li>Checkout the code from <a href="https://github.com/wso2/product-apim">https://github.com/wso2/product-apim</a> <em>master</em> branch if you have not already done so.</li><li>Navigate to <strong><em>apim-apps</em></strong> folder and run the following command skipping the tests.</li></ul><pre>mvn clean install -Dmaven.test.skip=true</pre><ul><li>After the build is successful, navigate to <strong><em>product-apim/all-in-one-apim</em></strong> folder and open the <strong><em>/product-apim/all-in-one-apim/pom.xml</em></strong> file. Then change the following entry with the value found in <em>&lt;version&gt;…&lt;/version&gt;</em> element in the <strong><em>/apim-apps/pom.xml</em></strong> file. For example with <strong>9.0.488-SNAPSHOT</strong>.</li></ul><pre>&lt;!-- APIM Portals Component Version --&gt;<br>&lt;carbon.apimgt.ui.version&gt;9.0.488-SNAPSHOT&lt;/carbon.apimgt.ui.version&gt;</pre><ul><li>Now build the <strong><em>product-apim</em></strong> repo and obtain the built pack similar to how this is done for the <strong><em>carbon-apimgt</em></strong> repo.</li></ul><h4>Bonus Tip! 🙂</h4><p>There is always an option to do the changes easily and check yourself without having to build the entire pack from the beginning. You can follow the steps given in the following articles to see how that can be done.</p><ol><li><a href="https://tharika.medium.com/how-to-apply-java-code-changes-to-wso2-server-on-the-go-caba252370">How to apply Java code changes to WSO2 server on the go?</a></li><li><a href="https://tharika.medium.com/how-to-apply-changes-to-wso2-api-manager-react-portals-on-the-go-d1cbb50f3819">How to apply changes to WSO2 API Manager React Portals on the go?</a></li></ol><h3><strong>How to build the pack with tests?</strong></h3><p>This step is really important if you want to send a PR to the <strong><em>carbon-apimgt, apim-apps </em></strong>or <strong><em>product-apim</em></strong> repositories.</p><p>Before sending a PR you should build the repositories <strong>with tests</strong> as follows to make sure that your changes have not caused any issues and have broken the existing tests.</p><ul><li>Navigate to <strong>carbon-apimgt</strong> folder and execute the following command. This will run the <strong>unit tests</strong> found in <strong>carbon-apimgt</strong> repository. This step would take a bit of extra time than when building the repository without tests.</li></ul><pre>mvn clean install</pre><ul><li>Navigate to the <strong>apim-apps</strong> repository and run the following command to build the repo. To run the tests use the steps given in the <a href="https://github.com/wso2/apim-apps?tab=readme-ov-file#unit-tests">README.md</a> file of the apim-apps repo.</li></ul><pre>mvn clean install</pre><ul><li>If these builds with tests are successful, navigate to <strong><em>product-apim/all-in-one-apim</em></strong> folder and make sure to change the <em>&lt;carbon.apimgt.version&gt; or &lt;carbon.apimgt.ui.version&gt;</em> in <strong><em>/product-apim/all-in-one-apim/pom.xml</em></strong> file as necessry.</li><li>Now execute the following command to build the <strong><em>product-apim</em></strong> repository with tests. This will run the build with <strong>integration tests</strong>. This step would take a considerable amount of time. Approximately 2 to 3 hours.</li></ul><pre>mvn clean install</pre><ul><li>After both the builds are successful, you can initiate your PR to the <strong><em>carbon-apimgt, apim-apps </em></strong>or <strong><em>product-apim</em></strong> repository as required.</li></ul><h3><strong>Where to select issues to work on?</strong></h3><p>If you want to select issues to work on, pick one from the <a href="https://github.com/wso2/api-manager/issues">api-manager</a> repository. If there are any doubts that you need to clarify regarding the issue you have picked, you can reply to the Git Issue and get feedback from WSO2 API Manager Team and the community.</p><p>Thank you for reading the article!</p><p>If you find any outdated content or issues with this article, please feel free to create an issue at <strong>Developer Corner</strong> Git repository <a href="https://github.com/tharikaGitHub/developer-corner">here</a>. Let’s grow together and help others in their journey too!</p><p>If you like this article please give it a clap. 🙂</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65d96fa9665c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to apply changes to WSO2 API Manager React Portals on the go?]]></title>
            <link>https://tharika.medium.com/how-to-apply-changes-to-wso2-api-manager-react-portals-on-the-go-d1cbb50f3819?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1cbb50f3819</guid>
            <category><![CDATA[portal]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[wso2developercorner]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 10:18:40 GMT</pubDate>
            <atom:updated>2025-10-09T08:15:36.167Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you want to easily apply changes to the React Portals then and there when you are doing UI changes? Then this article is for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wuEUDAkSJw0qIIAOK4qoiw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@cookiethepom?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Cookie the Pom</a> on <a href="https://unsplash.com/s/photos/computer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>When you are doing <strong>UI changes</strong> to one of the following React Portals in WSO2 API Manager, it is tiering to rebuild the project for every minor change you do.</p><ol><li><strong>Publisher Portal</strong> (Accessed through <a href="https://localhost:9443/publisher)"><em>https://localhost:9443/publisher</em>)</a></li><li><strong>Developer Portal</strong> (Accessed through <a href="https://localhost:9443/devportal)"><em>https://localhost:9443/devportal</em>)</a></li><li><strong>Admin Portal</strong> (Accessed through <a href="https://localhost:9443/admin)"><em>https://localhost:9443/admin</em>)</a></li></ol><p>So let me show you how this can be very easily done in only <strong>4 steps</strong>. The trick is to create a <strong>symlink</strong> between the portal apps and the directory containing the portal code. I’ll be using the <strong>Publisher Portal</strong> as the example here. You can do the same for other portals as well.</p><p>I currently use the following specs for <strong>node</strong> and <strong>npm</strong> versions. You can <strong>use the latest.</strong></p><blockquote><strong>node :</strong> v22.9.0</blockquote><blockquote><strong>npm :</strong> 10.8.3</blockquote><h4><strong>Step 1 :</strong></h4><p>Go to <strong><em>&lt;APIM_HOME&gt;/repository/deployments/server </em></strong>directory<strong><em> </em></strong>and<strong><em> </em></strong>copy the <strong><em>webapps</em></strong> folder in it. Move the copied folder to a different location and now delete the <strong><em>webapps</em></strong> folder in <strong><em>&lt;APIM_HOME&gt;/repository/deployments/server </em></strong>directory.</p><h4>Step 2 :</h4><p>Create a <strong>symlink </strong>between the <strong><em>webapps</em></strong> folder that was copied to a different location in step 1 <em>(&lt;full_path_to&gt;/webapps)</em> and the <strong><em>&lt;APIM_HOME&gt;/repository/deployments/server/webapps </em></strong><em>directory</em><strong><em> </em></strong><em>(&lt;full_path_to&gt;/&lt;APIM_HOME&gt;/repository/deployment/server)</em><strong><em> </em></strong>using the following command.</p><pre><strong>ln -s</strong> &lt;full_path_to&gt;/webapps &lt;full_path_to&gt;/&lt;APIM_HOME&gt;/repository/deployment/server</pre><p>Note that this will create a new symlinked folder named <strong><em>webapps</em></strong> in the path <em>&lt;full_path_to&gt;/&lt;APIM_HOME&gt;/repository/deployment/server</em>.</p><h4><strong>Step 3 :</strong></h4><p>Now execute the following commands in the given order, to get started.</p><pre>cd &lt;full_path_to&gt;/webapps<br><br>npm install<br><br>npm run bootstrap<br><br>cd publisher<br><br>npm ci<br><br>npm run build:prod<br><br>npm run build:dev</pre><p>The command npm run build:dev will keep watching for the changes you do in the source files of the <em>&lt;full_path_to&gt;/webapps/publisher</em> folder.</p><h4>Step 4:</h4><p>Now start the APIM server by running the api-manager.sh or api-manager.bat file in <em>&lt;APIM_HOME&gt;/bin </em>folder depending on your operating system.</p><p><strong>Note :</strong> When you do a change to the UI code, <strong>save it and reload</strong> the URL in the browser. This will reflect your latest changes.</p><h3>Bonus Tip! 🙂</h3><p>Before committing code, make sure to run the following command from within the directories of the respective portal application. This will catch any <strong>esLint</strong> errors and other critical issues found in the changed code.</p><pre>npm run build:prod</pre><p>Thank you for reading the article!</p><p>If you find any outdated content or issues with this article, please feel free to create an issue at <strong>Developer Corner</strong> Git repository <a href="https://github.com/tharikaGitHub/developer-corner">here</a>. Let’s grow together and help others in their journey too!</p><p>If you like this article please give it a clap. 🙂</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1cbb50f3819" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to apply Java code changes to WSO2 server on the go?]]></title>
            <link>https://tharika.medium.com/how-to-apply-java-code-changes-to-wso2-server-on-the-go-caba252370?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/caba252370</guid>
            <category><![CDATA[patch]]></category>
            <category><![CDATA[wso2developercorner]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 10:17:39 GMT</pubDate>
            <atom:updated>2025-01-15T07:15:28.884Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you want to easily push changes to the running server without having to build the pack over again? Then this article is for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y-2A3st4DKxOtzesRgDETw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@goran_ivos?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Goran Ivos</a> on <a href="https://unsplash.com/s/photos/code-on-the-go?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>When you are actively building WSO2 Products, it will be a real hassle to do a simple java code change and rebuild the entire pack over again to see if the change you did actually works. Urgh it sucks! 😖</p><p>In this article I will show you how this can be easily overcome. It’s very simple.</p><p>I will take the code base of <a href="https://wso2.com/api-manager/">WSO2 API Manager</a> for example here. Consider <a href="https://github.com/wso2/carbon-apimgt/blob/master/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/jwt/JWTValidatorImpl.java">this file</a> in the <a href="https://github.com/wso2/carbon-apimgt"><strong>carbon-apimgt</strong> repository</a>. Assume that you want to do a change in this file.</p><p><strong>Question:</strong> When you have an already built WSO2 API Manager pack running in your machine, how can you apply the new fixes to this existing pack without building a new one?</p><h4>Let’s dive in and find the answer! 🙂</h4><ul><li>Now you can see that the <strong>JWTValidatorImpl.java</strong> file <a href="https://github.com/wso2/carbon-apimgt/blob/master/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/jwt/JWTValidatorImpl.java">here</a> is located inside the parent package <strong><em>org.wso2.carbon.apimgt.impl</em></strong>. Assume you did a change in this file. And you can see that if you build this <strong><em>impl</em></strong> package alone, you will get a <strong><em>.jar</em></strong> file in its <strong><em>target</em></strong> folder. This newly built .jar has your changes in it.</li><li>In the WSO2 API Manager pack(server) that you are running in your machine right now, all these component .jar files are packaged inside the <strong><em>&lt;API-M_HOME&gt;/repository/components/plugins</em></strong> folder.</li><li>You will be able to see a .jar file with a similar name like this in the plugins directory.</li></ul><blockquote>org.wso2.carbon.apimgt.impl_9.30.98.SNAPSHOT.jar</blockquote><ul><li>This is the original .jar file of the <strong><em>impl</em></strong> package that you got when building the entire pack before. With this structure in place, there is an easier way to apply the new changes to the existing pack without building a new one. Can you see it now?</li><li>You guessed it right. But we are not going to replace this .jar with the new <strong><em>impl</em></strong> package .jar file. 🤓</li><li>You can see that there is another folder named <strong><em>patches</em></strong> in the <strong><em>&lt;API-M_HOME&gt;/repository/components</em></strong> directory. We are going to put the new <strong><em>impl</em></strong> jar into this as a <strong>patch</strong>.</li><li>Create a new folder named <strong><em>patch9999</em></strong> inside the patches folder and put the new .jar into it.</li><li>Rename the jar by replacing the <strong>hyphens</strong> with <strong>underscore</strong> and <strong>dot</strong> respectively as follows.</li></ul><blockquote>org.wso2.carbon.apimgt.impl-9.30.98-SNAPSHOT.jar → <strong>org.wso2.carbon.apimgt.impl_9.30.98.SNAPSHOT.jar</strong></blockquote><ul><li>Remember that the <strong>version</strong> of this jar should be the same as the original jar present in the <strong><em>plugins</em></strong> folder above. If the existing version is different from the newly built jar, you will have to rebuild the entire pack. No choice otherwise. 😐 The version can change if you fetched code from upstream after originally building the pack and later built the <strong><em>impl</em></strong> jar with your change. If an auto release has been triggered in the upstream git repository, the versions change automatically. Got it?</li><li>Now you must <strong>restart the server</strong> for the changes to take effect. When the server restarts, you will see the following log in the terminal to indicate that the patch changes are detected and applied.</li></ul><pre>INFO {org.wso2.carbon.server.extensions.PatchInstaller perform} — <strong>Patch changes detected</strong><br>INFO {org.wso2.carbon.server.util.PatchUtils applyServicepacksAndPatches} — <strong>Backed up plugins to patch0000</strong><br>INFO {org.wso2.carbon.server.util.PatchUtils checkMD5Checksum} — <strong>Patch verification started</strong><br>INFO {org.wso2.carbon.server.util.PatchUtils checkMD5Checksum} — <strong>Patch verification successfully completed</strong></pre><ul><li>What is this <strong>“<em>Backed up plugins to patch0000”</em></strong><em> </em>log above? After restarting the server, you will see a new folder created alongside patch9999. That is patch0000 to which the original jar files present in the plugins directory are backed up before applying the new change. Now the <strong><em>impl</em></strong> package jar file found inside the <strong><em>plugins</em></strong> folder is the newly changed jar. So do not delete the patch0000 folder as it is a backup of the original and you need it if you want to go back to the original state.</li><li>So now let’s see the steps in <strong>summary</strong> below.</li></ul><blockquote>1. Navigate to the parent package of the java file where you did the change and build it by executing the <strong>mvn clean install -Dmaven.test.skip=true</strong> command skipping the tests.</blockquote><blockquote>2. Put the jar into <strong><em>patches9999</em></strong> folder inside <strong><em>&lt;API-M_HOME&gt;/repository/components/patches </em></strong>directory after renaming the file replacing hyphens with underscore and dot respectively.</blockquote><blockquote>3. Restart the server.</blockquote><p>Now you can make your development journey more effective with this approach. Isn’t it? 🙂</p><p><strong>Bonus Tip</strong> <strong>:</strong> If you want to remove the change you just applied to the pack, simply remove the patch9999 folder and restart the server. In case if you have added multiple different jars to the patch9999 folder(based on your fix) and you need to revert the changes done to a specific jar(s) only, you can remove only the specific jar(s) from patch9999 and restart the APIM server.</p><p>Thank you for reading the article!</p><p>If you find any outdated content or issues with this article, please feel free to create an issue at <strong>Developer Corner</strong> Git repository <a href="https://github.com/tharikaGitHub/developer-corner">here</a>. Let’s grow together and help others in their journey too!</p><p>If you like this article please give it a clap. 🙂</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=caba252370" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to contribute to WSO2 API Manager Documentation?]]></title>
            <link>https://tharika.medium.com/how-to-contribute-to-wso2-api-manager-documentation-88911873a65e?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/88911873a65e</guid>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[wso2developercorner]]></category>
            <category><![CDATA[contribution]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 10:16:33 GMT</pubDate>
            <atom:updated>2025-10-06T09:02:46.472Z</atom:updated>
            <content:encoded><![CDATA[<p>Want to become a contributor for WSO2 API Manager docs? Then this article is for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OdxJdQYGBfK9hcLiAUn9mQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@aaronburden?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Aaron Burden</a> on <a href="https://unsplash.com/s/photos/aaron-burden-y02jex_b0o0-unsplash-writing?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I will keep this article as simple as possible so that you can dive in right away. Short and Sweet! 🙂</p><ul><li><strong>Link to the documentation</strong> → <a href="https://apim.docs.wso2.com/en/latest/">https://apim.docs.wso2.com/en/latest/</a></li><li><strong>GitHub repository for docs</strong> → <a href="https://github.com/wso2/docs-apim">https://github.com/wso2/docs-apim</a></li><li><strong>Active branch for next release documentation</strong> → master</li><li><strong>Branches for previous releases</strong> → Named after the release version. For example, branch 4.2.0 is for the documentation of WSO2 API Manager version 4.2.0.</li><li><strong>Technology used for writing</strong> → MkDocs</li></ul><h3>How to get started?</h3><ul><li><strong>Fork</strong> the <a href="https://github.com/wso2/docs-apim">docs-apim</a> repo.</li><li><strong>Clone the fork</strong> of <a href="https://github.com/wso2/docs-apim">docs-apim</a> repo to your local machine.</li><li>Set <strong>remote upstream</strong> of the Git repository to <a href="https://github.com/wso2/docs-apim.git">https://github.com/wso2/docs-apim.git</a>. You can use the command below.</li></ul><pre>git remote add upstream <a href="https://github.com/wso2/docs-apim.git">https://github.com/wso2/docs-apim.git</a></pre><ul><li>Install <strong>Python</strong></li><li>Install<strong> pip</strong></li><li>Install the <strong>required pip packages</strong> using the following commands. If you are using Python 2, use <strong><em>pip</em></strong> command and if you are using Python 3, use <strong><em>pip3</em></strong> command.</li></ul><pre>pip install mkdocs<br>pip install mkdocs-material<br>pip install markdown-include<br>pip install pymdown-extensions</pre><p>This will install <strong>MkDocs</strong> for you.</p><p>Now you are done with the setup required to start with writing documentation. 👍</p><p>To see if MkDocs is correctly installed, run the following command in the terminal. It will print the version of MkDocs if it is correct.</p><pre>mkdocs —-version</pre><h3>Start the local MkDocs Server</h3><ul><li>Now move into the <strong><em>docs-apim/en/</em></strong> folder in the cloned repository. Remember to checkout to the correct branch based on the documentation that you need to edit.</li></ul><pre>cd docs-apim/en/</pre><ul><li>Run the following command to start the server.</li></ul><pre>mkdocs serve</pre><p>When you see the following log, in the terminal that you executed the command above, you can access the server using the given url (<a href="http://localhost:8000/">http://localhost:8000</a>) from the browser. This is the docs server running locally in your machine.</p><pre>[I 210110 08:11:35 server:335] Serving on <a href="http://localhost:8000/">http://localhost:8000</a><br>[I 210110 08:11:35 handlers:62] Start watching changes</pre><p>Now you can edit the document and view your changes locally by running <strong><em>mkdocs serve.</em></strong> Make sure to reload the browser to view your changes. After making a change, you have to save it and wait for the above log to reappear.</p><h3>View edited docs on the fly</h3><p>If you want to view the edited docs on the fly without having to manually reload the browser, follow the steps below.</p><ul><li>Open <strong><em>docs-apim/en/mkdocs.yml</em></strong> file.</li><li>Change the following configuration to false as fallows.</li></ul><pre>#Breaks build if there’s a warning<br>strict: false</pre><ul><li>Now run the following command which will allow you to make the server load only the changed items and display the changes faster without having to manually reload the browser.</li></ul><pre>mkdocs serve --dirtyreload</pre><p>Make sure to change the above configuration to <strong>true</strong> again when committing your changes. In a particular branch, if it is false by default, leave it as it is.</p><h3>Where to make the changes?</h3><p>Here I will explain to you the basic but most important things you should know when making changes to the documentation.</p><ul><li>It is in the <strong><em>docs-apim/en/mkdocs.yml </em></strong>file, that we define the paths to the relevant <strong><em>.md</em></strong> file that contains content for a specific topic. You can find that under the <strong>nav section</strong> as shown below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IZ-LVwWzujkTQETJ9-0r7w.png" /><figcaption>mkdocs.yml</figcaption></figure><ul><li>Find the relevant <strong><em>.md</em></strong> file from the <strong><em>mkdocs.yml</em></strong> file and make changes accordingly. Under the nav section, on the left of the key value pairs is what you see as headings in the documentation when accessing through the browser. This will help you to find the respective document easily.</li><li>If you are planing to include <strong>screenshots</strong> in the page that you are writing, add all the images in to the following location.</li></ul><blockquote><strong>docs-apim/en/docs/assets/img/&lt;relevant-folder&gt;</strong></blockquote><ul><li>Name the images in simple letters and separate the words with a hyphen. For example, <em>create-new-api.png</em>. The <strong><em>relevant-folder</em></strong> can be decided based on the location of the documentation. For example if you are adding an image to <em>create-a-rest-api.md</em> file, add it under its <strong>super parent section</strong> which is <strong>“<em>learn”</em></strong> according to the structure in <em>mkdocs.yml</em> file.</li><li>When adding screenshots or images to the documentation, to view them locally, change the image file path as follows. Remove <strong>{{base_path}}</strong> from the url and add the relative path to the assets folder where the image resides.</li></ul><blockquote>![Create WebSocket API menu](../../assets/img/learn/create-websocket-api.jpg)</blockquote><p>But when committing the changes to the repository, make sure to change it to <strong><em>{{base_path}}</em></strong> again. For your information, this <strong>base_path</strong> is defined in <strong><em>mkdocs.yml</em></strong> file.</p><blockquote><strong>Note:</strong> You can also instead change the <strong><em>base_path</em></strong> entry in the <strong><em>mkdocs.yml</em></strong> file to localhost url to make the new images appear locally. When sending a PR, make sure to revert this change.</blockquote><h3>Best practises to follow</h3><p>Make sure you follow the practises defined in <a href="https://github.com/wso2/docs-apim/wiki/Introduction">this wiki</a> when making changes to the <strong><em>docs-apim</em></strong> repository.</p><p>You can now start contributing to WSO2 API Manager documentation and play your part to increase your visibility and competency.</p><p><strong>Note :</strong> Please refer <a href="https://github.com/wso2/docs-apim/issues">this link</a> to see what issues need to be addressed. If you are making any changes to an already released version of WSO2 API Manager, make sure to send in a PR to the master branch as well, if the change is applicable.</p><p>If you find any outdated content or issues with this article, please feel free to create an issue at <strong>Developer Corner</strong> Git repository <a href="https://github.com/tharikaGitHub/developer-corner">here</a>. Let’s grow together and help others in their journey too!</p><p>If you like this article please give it a clap. 🙂</p><p>Cheers! Happy Contributing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88911873a65e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What am I missing in WSO2 API Manager 3.x datasource configuration?]]></title>
            <link>https://tharika.medium.com/how-to-configure-datasources-in-wso2-api-manager-3-x-d28611a3bb26?source=rss-e10a48267e46------2</link>
            <guid isPermaLink="false">https://medium.com/p/d28611a3bb26</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[wso2-api-manager-3]]></category>
            <category><![CDATA[datasource]]></category>
            <category><![CDATA[configuration]]></category>
            <category><![CDATA[template]]></category>
            <dc:creator><![CDATA[Tharika Madurapperuma]]></dc:creator>
            <pubDate>Sat, 05 Dec 2020 09:49:42 GMT</pubDate>
            <atom:updated>2020-12-05T10:33:15.954Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OyeNmhElsADd237nBkeoMQ.jpeg" /></figure><p>In this article I will be showing you how the datasources can be configured in <a href="https://wso2.com/api-management/"><strong>WSO2 API Manager</strong></a> <strong>3.x products</strong> because this approach is different than what we had in our 2.x family of products configuring the <strong><em>master-datasources.xml</em></strong>.</p><p>The main intention of this change was to allow the users to make changes in a single location reducing the hassle of having to deal with multiple configuration files. Therefore you need to edit only the <strong><em>deployment.toml</em></strong> file in <em>&lt;APIM_HOME&gt;/repository/conf</em> directory.</p><p>👇</p><p>At the end I will be providing you with a <strong>Bonus Tip 😍</strong> which will <strong>help you do any configuration on your own without seeking help from someone else</strong>. 🥳</p><h4>Main datasources that can be configured in WSO2 API Manager 3.x</h4><ol><li>WSO2AM_DB</li><li>WSO2_SHARED_DB</li><li>WSO2_CARBON_DB</li><li>WSO2USER_DB</li><li>WSO2CONFIG_DB</li><li>WSO2_MB_STORE_DB</li></ol><p><strong>Note :</strong> You might be wondering what happened to WSO2AM_STATS_DB. This datasource is no longer needed in WSO2 API Manager product as you should be configuring it in WSO2 API Manager Analytics instead.</p><h4>Datasources configured by default</h4><p>There are 2 datasource configurations that are already available in the <strong><em>deployment.toml</em></strong> file.</p><p>They are for <strong>WSO2AM_DB</strong> and <strong>WSO2_SHARED_DB</strong>.</p><p><strong>WSO2AM_DB</strong> is one of the main datasources in WSO2 API Manager and is used for storing everything related to API Manager artifacts. This is configured by the following lines in the <em>deployment.toml</em> file in the product. See the default configuration.</p><pre>[database.apim_db]<br>type = &quot;h2&quot;<br>url = &quot;jdbc:h2:./repository/database/WSO2AM_DB;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE&quot;<br>username = &quot;wso2carbon&quot;<br>password = &quot;wso2carbon&quot;</pre><p><strong>WSO2_SHARED_DB</strong> is the shared datasource for both user and registry related data. This is the next important datasource in WSO2 API Manager. See the default configuration of this datasource below.</p><pre>[database.shared_db]<br>type = &quot;h2&quot;<br>url = &quot;jdbc:h2:./repository/database/WSO2SHARED_DB;DB_CLOSE_ON_EXIT=FALSE&quot;<br>username = &quot;wso2carbon&quot;<br>password = &quot;wso2carbon&quot;</pre><p>Then comes the datasources that you might want to configure yourself depending on the need. Otherwise they are not needed to be specifically configured.</p><h4>WSO2_CARBON_DB</h4><p>You will not see this datasource configuration in the default settings of the <em>deployment.toml</em> file specifically in WSO2 API Manager 3.0.0, because it is sufficient to use the already configured embedded h2 datasource for this. But if you need to configure it to point to a datasource of your choice, use the following configs and add it(if not already available) to the <em>&lt;APIM_HOME&gt;/repository/conf/deployment.toml</em> file. Else edit the existing configuration.</p><pre>[database.local]<br>type = &quot;h2&quot;<br>url = &quot;jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;MVCC=TRUE&quot;<br>username = &quot;wso2carbon&quot;<br>password = &quot;wso2carbon&quot;</pre><p>The changes will be applied on server startup.</p><p><strong>Note :</strong> But if you have multiple server nodes of WSO2 API Manager running, make sure that each node has its own WSO2_CARBON_DB in the case that you will change the embedded h2 database to one of your choice.</p><h4>WSO2USER_DB</h4><p>This is the datasource where user related data are stored (an optional datasource). If this datasource is not configured, all user related data will be stored in the WSO2_SHARED_DB<strong>.</strong></p><p>So use this if you need a separate datasource for users. Then, only the registry or governance related data will be stored in the WSO2_SHARED_DB.</p><p>Add the following lines to the <em>deployment.toml</em> file in order to configure a separate WSO2USER_DB.</p><pre>[database.user]<br>type = &quot;h2&quot;<br>url = &quot;jdbc:h2:./repository/database/WSO2USER_DB;DB_CLOSE_ON_EXIT=FALSE&quot;<br>username = &quot;wso2carbon&quot;<br>password = &quot;wso2carbon&quot;</pre><h4><strong>WSO2CONFIG_DB</strong></h4><p>This is the datasource used for config registry (an optional datasource). If this datasource needs to be configured, add the following lines to the <em>deployment.toml</em> file and modify it with your data.</p><pre>[database.config]<br>type = &quot;h2&quot;<br>url = &quot;jdbc:h2:./repository/database/WSO2CONFIG_DB;DB_CLOSE_ON_EXIT=FALSE&quot;<br>username = &quot;wso2carbon&quot;<br>password = &quot;wso2carbon&quot;</pre><h4>WSO2_MB_STORE_DB</h4><p>This is the datasource used for the message broker database. You can use the embedded h2 database as the WSO2_MB_STORE_DB even in production. Hence it is not required to configure this database separately.</p><h4>You can even add your own datasources into the product</h4><p>You can use <strong>custom datasources</strong> if required with the extension capabilities that WSO2 API Manager provides.</p><p>Use the following approach when configuring one or more custom datasources.</p><p><strong>Note :</strong> You can replace <strong><em>my_custom_db</em></strong> with your preferred name. Make sure you provide all necessary parameters to the configuration below such as the id, url, type, driver, username, password etc. The <strong>“id”</strong> can be one of your choice.</p><pre>[datasource.my_custom_db]<br>type = &quot;h2&quot;<br>id = &quot;CUSTOM_DB&quot;<br>url = &quot;jdbc:h2:./repository/database/MYCUSTOM_DB&quot;<br>username = &quot;wso2carbon&quot;<br>password = &quot;wso2carbon&quot;<br>validationQuery = &quot;SELECT 1&quot;<br>driver = &quot;org.h2.Driver&quot;</pre><p>If you have <strong>more than one custom datasource</strong>, repeatedly add the above configuration in the <em>deployment.toml</em> file and modify it with the configuration you need.</p><p>Now after doing all the above changes as needed, you should <strong>restart</strong> the server for the changes to apply. Then you can check the <strong><em>&lt;APIM_HOME&gt;/repository/conf/datasources/master-datasources.xml</em></strong> file content being updated with the configurations you have provided in the <strong><em>deployment.toml </em></strong>file.</p><h3>Bonus Tip 😃</h3><p>In <em>&lt;APIM_HOME&gt;/repository/resources/conf/templates/repository/conf/datasources</em> directory you will find a <strong><em>master-datasources.xml.j2</em></strong> file. It is the file that is used to template the original <strong>master-datasources.xml </strong>file available in <em>&lt;APIM_HOME&gt;/repository/conf</em> directory.</p><p>If you look closely at <strong><em>master-datasources.xml.j2</em></strong>, you will see how a particular datasource is templated. Let me take the <strong>WSO2AM_DB</strong> datasource template to explain it to you.</p><pre>&lt;datasource&gt;<br>    &lt;name&gt;WSO2AM_DB&lt;/name&gt;<br>    &lt;description&gt;The datasource used for API Manager<br>database&lt;/description&gt;<br>    &lt;jndiConfig&gt;<br>        &lt;name&gt;jdbc/WSO2AM_DB&lt;/name&gt;<br>    &lt;/jndiConfig&gt;<br>    &lt;definition type=&quot;RDBMS&quot;&gt;<br>        &lt;configuration&gt;<br>            &lt;url&gt;{{database.apim_db.url}}&lt;/url&gt;<br>            &lt;username&gt;{{database.apim_db.username}}&lt;/username&gt;<br>            &lt;password&gt;{{database.apim_db.password}}&lt;/password&gt;<br>            &lt;driverClassName&gt;{{database.apim_db.driver}}<br>            &lt;/driverClassName&gt;<br>            &lt;validationQuery&gt;{{database.apim_db.validationQuery}} <br>            &lt;/validationQuery&gt;<br>           {% for property_name,property_value in database.apim_db.pool_options.items() %}<br>                  &lt;{{property_name}}&gt;{{property_value}}&lt;/{{property_name}}&gt;<br>           {% endfor %}<br>       &lt;/configuration&gt;<br>   &lt;/definition&gt;<br>&lt;/datasource&gt;</pre><p>Look at the above template and try to map it to the <strong><em>deployment.toml </em></strong>configuration below.</p><pre>[database.apim_db]<br>type = &quot;h2&quot;<br>url = &quot;jdbc:h2:./repository/database/WSO2AM_DB;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE&quot;<br>username = &quot;wso2carbon&quot;<br>password = &quot;wso2carbon&quot;</pre><ul><li><strong><em>{{database.apim_db.url}}</em></strong> = The <strong>url</strong> element under [databases.apim_db] configuration.</li><li><strong><em>{{database.apim_db.username}}</em></strong> = The <strong>username</strong> element under [databases.apim_db] configuration.</li><li><strong><em>{{database.apim_db.password}}</em></strong> = The <strong>password</strong> element under [databases.apim_db] configuration.</li></ul><p>Then what about <strong><em>{{database.apim_db.driver}}</em></strong>…?</p><p>If we have not specified this element in the <em>deployment.toml</em> file, there is a place that we take the default configuration value for it.</p><p>It is…</p><p><strong><em>&lt;APIM_HOME&gt;/repository/resources/conf/default.json</em></strong></p><p>Following is the entry we can see in the <em>default.json</em> file.</p><pre>&quot;database.apim_db.driver&quot;: &quot;org.h2.Driver&quot;,</pre><p><strong>Note :</strong> We shouldn’t be editing the <strong><em>default.json</em></strong> file. Instead, all configuration changes should be done in the <strong><em>deployment.toml</em></strong> file. The reason being, if you take a <a href="https://wso2.com/updates/wum">WUM</a> update for the product, all changes that you have done in <em>default.json</em> will be replaced if it contains changes that has come through a fix. You don’t want this happening right? 🙂 So avoid changing the <em>default.json</em>.</p><p>Okay let’s come back…</p><p>Now look at this line in the WSO2AM_DB configuration in the <strong><em>master-datasources.xml.j2</em></strong> file above.</p><pre>{% for property_name,property_value in database.apim_db.pool_options.items() %}</pre><p>What is this for loop for?</p><p>If you have any <strong>additional properties</strong> that should be configured for the datasource, you have to specify them in the <strong><em>deployment.toml</em></strong> file under the configuration <em>[database.apim_db.pool_options]</em> in the form of key value pairs. This is specific for the WSO2AM_DB. Other datasource configurations also have the same capability. See the sample configuration below.</p><pre>[database.apim_db.pool_options]<br>minIdle = &quot;10&quot;<br>removeAbandoned = true<br>removeAbandonedTimeout = &quot;180&quot;<br>logAbandoned = true<br>maxActive = &quot;150&quot;</pre><p>With this knowledge, you will be able to specify any property for a datasource that you need to configure in WOS2 API Manager by simply looking at the <strong><em>master-datasources.xml.j2</em></strong> template file. 👏</p><p>😇 This can successfully be applied to any other configuration you see in WSO2 API Manager. You have to simply look at the relevant template file which can be found from the location <strong><em>&lt;APIM_HOME&gt;/repository/resources/conf/templates/repository/conf</em></strong> and add the required configuration in the <strong><em>deployment.toml</em></strong> file.</p><p>Cheers !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d28611a3bb26" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>