Wednesday, February 18, 2009

Deploying WSO2 ESB 2.0 on Apache Tomcat

As you all know WSO2 ESB can be deployed on different application servers such as IBM WebSphere, BEA WebLogic Server, JBoss and Apache Tomcat. I have written a blog previously on how one can deploy WSO2 ESB on Apache Tomcat. Unfortunately this does not work with the new Carbon based WSO2 ESB. Therefore for anyone who is interested on deploying WSO2 ESB on Apache Tomcat the following guide will be useful.

Step 1 - Downloading and installing Apache Tomcat

You can download the latest version of Apache Tomcat from here (I will be using Apache Tomcat 5.5.20 to demonstrate this scenario).
Extract the downloaded distribution to a specific location and define the environment variables properly. (Assume you extracted the downloaded Tomcat into the folder C:\apache-tomcat-5.5.20)

E.g.: -
CATALINA_HOME=C:\apache-tomcat-5.5.20

Next you will need to enable HTTPS on Apache Tomcat since WSO2 ESB runs over HTTPS. To do this, access the server.xml file located at %CATALINA_HOME%/conf and uncomment the following.

<Connector port="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"/>

Then you will need to provide the keystore file location along with it's password as below.

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="C:\Carbon\ESB\tomcat_repo\resources\security\wso2carbon.jks"
keystorePass="wso2carbon"/>


Step 2 - Downloading and installing WSO2 ESB

Download the latest WSO2 ESB distribution from here and extract to a specific location. (E.g.:- C:\Carbon\ESB\tomcat\wso2esb-SNAPSHOT). From this folder copy the folders,

- conf
- database
- resources
- repository

to a separate folder. (E.g.:- C:\Carbon\ESB\tomcat\esb_home)

Step 3 - Setting environmental variables

You will have to set an environment variable with the name CARBON_HOME pointing it to the directory which you copied the above files to.
E.g.:-
CARBON_HOME=C:\Carbon\ESB\tomcat\esb_home

Step 4 - Copying required files to Apache Tomcat

Now create a folder inside the webapps folder of Tomcat.
E.g.:-
C:\apache-tomcat-5.5.20\webapps\esb

Next, you need to copy the WEB-INF folder, which is in the folder which you extracted the downloaded ESB distribution. Then copy it into the esb folder which you created above.
E.g.:-
Copy
C:\Carbon\ESB\tomcat\wso2esb-SNAPSHOT\webapps\ROOT\WEB-INF
to
C:\WSO2\Installations\apache-tomcat-5.5.20\webapps\esb


Step 5 - Changing necessary files of the WSO2 ESB distribution

a) Open the carbon.xml file which is in the CARBON_HOME\conf folder and specify the following URL as the ServerURL
E.g.:-
https://localhost:8443/esb/services/

b) Next open the axis2.xml which is located inside the CARBON_HOME\conf and change the http port from 8280 to 8080 (the default http port of Tomcat) and the https port from 8243 to 8443.
Note that you do not have to do this in the Carbon based WSO2 ESB distribution. Just leave the ports as they are.

c) In addition to the above, you need to specify the correct paths for the two .jks files wso2carbon.jks and client-truststore.jks specified in the axis2.xml and also the wso2carbon.jks file specified in the carbon.xml file.

d) Then you also have to change the contextRoot parameter value to /esb of the axis2.xml file
Instead of the above, in the Carbon based ESB you need to change the WebContextRoot parameter in the carbon.xml

e) Then you need to specify the absolute paths of the WSO2CARBON_DB of the two files registry.xml and user-mgt.xml
E.g.:- Change
jdbc:derby:database/WSO2CARBON_DB;create=true
to
jdbc:derby:C:\Carbon\ESB\tomcat\esb_home\WSO2CARBON_DB;create=true


f) Next you will have to specify the absolute path of the synapse.xml which is in the axis2.xml file located at CARBON_HOME\conf

E.g.:-
Change
conf/synapse.xml
to
C:\Carbon\ESB\tomcat\esb_home\conf\synapse.xml

Step 6 - Starting the Apache Tomcat Server

Now you can start the Apache Tomcat server by giving the following command.
catalina.bat run

Step 7 - Login to the WSO2 ESB Administration Console

Now you should be able to login to the WSO2 ESB Administration Console as, https://localhost:8443/esb/carbon