Tuesday, October 2, 2007

How to use Apache Tuscany with WebSphere 6.1

Recently a number of Apache Tuscany users started to use our Tuscany SCA 1.0 release on top of WebSphere v6.1 and ask questions about it on the tuscany-user list.

To be able to help I had to set up WebSphere v6.1 on my Laptop and configure it to work with Tuscany. It was pretty straightforward so I thought it'd be useful to share the steps here:

First install WebSphere v6.1.0.9. The "9" indicates WebSphere Fixpack 9, which contains a Fix for a WebSphere bug with Servlet filters... needed as Tuscany uses a Servlet filter to dispatch HTTP requests to SCA services.

Start your WebSphere server, then point your Web browser to the WebSphere console at http://localhost:9060/admin.

To activate that WebSphere Fix, navigate to Application Servers - server1 - Web Container - Customer Properties and configure a com.ibm.ws.webcontainer.invokefilterscompatibility property to true as described there.

Here's a screen capture showing what to do:

Download the Tuscany SCA release 1.0 binary distribution from http://incubator.apache.org/tuscany/sca-java-releases.html and untar or unzip it.

The distribution contains a number of ready to use samples. Let's start with samples/calculator-webapp.

This is a sample Calculator implemented with SCA components wired together, implementing the basic add, subtract, multiply, divide operations (in Java), and a JSP invoking the calculator.

Here's a diagram showing the SCA composite and how the SCA components are assembled together:

The sample README describes how to build the WAR file for the Webapp using Apache Ant, but the distribution already contains a WAR file ready to use, let's try to deploy it to WebSphere...

From the WebSphere Console page, navigate to Applications - Enterprise Applications. You should see the following page:

Click on the Install button, in the application installation form click Local file system - Browse and select:

In the Context root field, type sample-calculator-webapp as shown below:

Click Next to proceed with the installation, the following page will appear:

You don't need to change any of these settings, just click Next, the following page will appear:

Click Next, the following page will appear:

Click next... again :) the following page will appear:

Click Finish, installation will proceed and you should see the following page:

Now click Save to save the changes and make the installation effective. This will go back to the list of installed applications, you should now see sample-calculator-webapp, as shown here:

At this point the Calculator webapp has been installed. We just need to make a small change to its classloader configuration. This is necessary to allow Tuscany to find all its dependencies in the webapp itself instead of the WebSphere lib directory (as some of the Tuscany dependency JARs are newer than the ones that come with WebSphere).

To do that click on sample-calculator-webapp war in the Enterprise Applications list, you should see the following page:

Click the Class loading and update detection link, you should see the Class Loader configuration page. Select the "Classes loaded with application class loader first" and "Single class loader for application" options as shown here:

Click OK, then Save to save your changes. You should be back to the Enterprise Applications page.

You're now ready to start the Calculator sample!

Check the check mark beside sample-calculator-webapp war and click the Start button, you should see the following:

The application is running... time to point your Web browser to http://localhost:9080/sample-calculator-webapp/. The Calculator JSP will execute, and you should see the following:

That's it, you've run your first SCA application with Tuscany on WebSphere v6.1!

Note: That last screencap shows localhost:8080 instead of localhost:9080 but that's just because I've tweaked my server to use 8080 instead of the default 9080, I wanted the different servers on my laptop to use the same port number as having to juggle with different ports was driving me crazy :)

Last time I checked all samples from the Tuscany 1.0 release worked on WebSphere v6.1 ( or later) except for our helloworld-dojo-webapp sample.

If I find more time to blog in the next few days I'll try to describe some of these other samples and also quicker ways to deploy an SCA application using a script instead of clicking... if I find the time :)


Kalpesh Soni said...

Does this app use websphere's webservice engine, or does it still use axis2?

Jean-Sebastien Delfino said...

Apache Tuscany uses Apache Axis2.

The WebSphere Application Server v7 Feature Pack for SCA (which leverages core components of Tuscany) works with the WebSphere Web Services engine.

KLcw said...

I can get SCA running in WAS 7.0 with normal wireformat but not messageprocessor, any idea?

The postings on this site are my own and don’t necessarily represent positions, strategies or opinions of my employer IBM.