info@yenlo.com
eng
Menu
WSO2 5 min

WSO-2-EASY: Running API Manager on Windows

Vladimir_Klevko.jpg
Vladimir Klevko
Solution Architect
24 jun no 1

The WSO2 API Manager enables you to manage the API’s that your organization offers or wants to use. Like all WSO2 products it runs both on Windows and Linux machines. In order to collect, view and analyze statistics on the usage of API’s you can integrate with WSO2 BAM, no called WSO2 DAS (Data Analytics Server). The WSO2 API manager is part of the 100% open source integration platform called WSO2.

Prerequisites

It is however necessary to install CYGWIN on your windows machine. This is a collection of Linux tools that will provide functionality similar to a Linux distribution on Windows. You can find CYGWIN and the installation instructions here.

Make sure that the path to the Cygwin64/Bin directory is added to the windows path. You can check this after installation by starting the CMD program (search for CMD in Windows) and typing a Linux command like ls (list directory). If you get a response, e.g. an list of the directory structure, it works. If you get an error, there is something wrong with the PATH. Type in PATH (or echo %path%) in the CMD window and check for the Cygwin64/bin entry.

How to integrate BAM with API Manager

Recently at an API Manager training we integrated BAM with API as part of the training (it is one of the labs we do). The steps are relatively easy, it is a simple question of making the following changes.

We assume in this example that the WSO2 BAM has a port offset of 1, this means that the default port is increased by 1. Take a look at the API Manager documentation for information on how to do this.

This to enable to run API Manager and BAM on the same computer for testing purposes. You can see that is doing so by the ‘localhost’ entry that is used indicating running on a local computer.

1. First make changes in the /repository/conf/api-manager.xml file in the directory where you installed API Manager (we refer to it as [APIM_HOME]).

24_jun_no_1.png

2. Then you need to specify the datasource definition in both the <APIM_HOME> and <BAM_HOME> directory structure.

In <APIM_HOME>/repository/conf/datasources/master-datasources.xml file as follows. Please add a fully qualified path to the BAM HOME and use either forward slash (/) or backward slash() for the path.

24_jun_no_2.png

3. Copy the definition that you just added to the master-datasources.xml for the API Manager also to the bam_datasources.xml file (you can find it at BAM_HOME/repository/conf/datasources/bam_datasources.xml file)

4. Copy the file <APIM_HOME>/statistics/API_Manager_Analytics.tbox to directory. <BAM_HOME>/repository/deployment/server/bam-toolbox. If this folder is not in the BAM installation directory by default, create it. The toolbox describes the information collected, how to analyze the data, as well as the location of the database where the analyzed data is stored.

Restart the API Manager and Business Activity Monitor to access the overview. If there are no API statistics available you will see a screen with this message. When you for instance call an API you subscribed to for a number of times you will see the statistics from the use of the API’s.

Overall API Subscriptions

Errors

But at a training recently, one of the students followed all the steps to the letter but did not get the required response. Accessing the stats through the API Publisher showed the default screen saying that BAM was not properly integrated.

WSO2 API Publisher Errors

Furthermore, the log file gave a number of errors and warnings like Error occurred while querying from JDBC database’ and Table "API_REQUEST_SUMMARY" not found.

After checking all the settings for any typos comparing it to the settings from someone else in the training who did succeed to integrate BAM it was found that it looked like the settings were correctly entered. Both API Manager and BAM were restarted but to no avail. The errors persisted and it was not possible to see the statistics.

Cygwin was available in the path, so that could not be the problem. There had to be something outside the WSO2 products that made it work on one computer, but not on the other.

Length of Windows file names

After some serious searching it turned out that the location on the harddisk where the WSO2 products were installed resulted in a filename and path that was too long. Even the desktop where the files were stored is can be a problem since it is already a somewhat long name, namely C:Users[username]Desktop.

If you were to add a directory name like Training WSO2 APIM to that and within that directory the WSO2 products there is a reasonable change that the directory names will be too long. We do not know exactly what the maximum length can be in order to make it work but the shorter the names of the directories in the tree structure leading up to the WSO2 installation, the better.

Solution

The reason is that scripts and databases are created further down the directory tree and if the length exceed the maximum number of characters (255) the files are inaccessible. The solution is simple, if you are running on Windows, install the WSO2 components with short filenames as close to the root directory, e.g. c:WSAM etc.

Moving to another directory

If you encounter this error you can try and move the installation of BAM and API manager to another directory. However, in many cases for it to work you need to remove the content of the TMP directory in BAM (<BAM_HOME>TMP) as well as replace the database folder (<BAM_HOME>repositorydatabase) with a fresh copy from the WSO2 zip file.

Finally, since the location of the BAM directory has changed (you moved it to a different location) and you are pointing to that location from the bam_datasources.xml and the master-datasources.xml files you need to change the URL to point to the new location. Fill in the fully qualified name where it says <BAM_HOME> in both files.

<url>jdbc:h2:<BAM_HOME>/repository/database/APIMGTSTATS_DB;AUTO_SERVER=TRUE</url>

If you do not do this it might be that the components persist to point to the previous directory where BAM was installed.

This filename error is particular to Windows and does not occur on Linux based deployments of WSO2.

eng
Close