Deploying Flex on WebSphere Application Server

Increasingly as we step further in to the depths of the enterprise we find more and more of our customers are using WebSphere Application Server (WAS).

When it comes to using Flex Data Services (FDS) on WAS you must modify your Flex configuration if you want to use RTMP. I thought it would be beneficial to other developers taking their first tentative steps with FDS and WAS to walk through the steps necessary to deploy your Flex-based application on WAS. I have written this blog entry against WebSphere Application Server Base V6. This is IBM’s grown-up application server for which you pay a license fee. I haven’t used the community edition of WAS, which is based on Apache Geronimo. I hope to see Geronimo as a supported application server in the future.


So what’s different?

Very briefly, the intention behind the J2EE platform is to protect the developer from low-level coding such as multi-threading. As such, there are a number of restrictions in the J2EE programming model when it comes to multi-threading. For example, it is illegal to create your own threads in a J2EE container. This restriction makes asynchronous processing difficult. When asynchronous processing is required developers normally turn to the Java Messaging Service (JMS). However, this is not ideal when you want concurrent processing. In this case WAS provides a programming model extension (PME) for asynchronous beans that allows developers to to create work items that execute out of a thread pool (work manager) managed by the application server. The concept of a work manager is being standardised under JSR 237 (Work Managers for Application Servers) by IBM and BEA. It is also referred to as the CommonJ Work Manager specification and is part of the J2EE 1.4 specification.

There are other benefits to this PME, but we won’t cover them here. All I really wanted to say is the RTMP end-point is implemented using asynchronous beans, which requires us to configure the work manager (thread pool) for the RTMP work items.

The work manager is configured under the WAS admin console and is accessed using JNDI – this is what we need to configure!

There are also a couple of bits of configuration in Flex that we need to un-comment. The Flex configuration uses a resource-ref, which is essentially an alias that the code can use to refer to the resource – the work manager in our case. At deployment time we bind the resource-ref to the JNDI name of our resource. I won’t delve in to the benefits of using resource references other than to say they are considered best-practice. Finally, just so the config makes sense, an application uses the java:comp/env namespace when it is using a resource-ref.


So what do we do?

To start , I am going to assume you have WebSphere Application Server Base or higher installed.

Second, we need our resource-ref. Open the web desployment descriptor, web.xml, for your FDS application. At the bottom you will see the following commented out, which you need to un-comment:

Flex Messaging WorkManagerwm/

This defines the resource-ref for our work manager with the name wm/MessagingWorkManager. As I mentioned above the code looks up a resource-ref in the java:comp/env namespace. Therefore the full name that will be used in the code is java:comp/env/wm/MessagingWorkManager. With this in mind lets move on to our third step.

Edit services-config.xml and fine the definition for my-rtmp and you will see the following commented out, again you need to un-comment it:


This tells the RTMP end-point the name of the work manager to use, which is java:comp/env/wm/MessagingWorkManager.

Next start WAS and log in to the admin console (http://localhost:9060/ibm/console/).

From the admin console navigate to Resources >Asynchronous beans > Work managers.

Click the New button and configure your work manager as follows:

JNDI name
Number of alarm threads 5
Minimum number of threads 1
Maximum number of threads 10
Thread Priority 5
Growable true

Tip: the Work Manager thread pool is definetly going to be something you want to monitor and tune during performance and scalability testing (before your application goes in to production). You can monitor the work manager with the Tivoli Performance Viewer, which is included with WebSphere Application Server Base (this is why I like to start to like WAS – it’s the value of the supporting tools and documentation).

Save your configuration and restart your server.

You can now deploy your application using the admin console where you will be required to bind your resource reference (i.e. wm/MessagingWorkManager) to the JNDI name of your work manager (i.e. wm/MessagingWorkManager). Yes they are both called the same in our example, but they don’t need to be.


What about deploying the application from the command line?

If you want to deploy on the command line or genrally avoid specifying the binding at deploy time you can define your resource binding in IBM’s binding file (ibm-web-bnd.xmi). You will need an id on your resource-ref and an associated binding in ibm-web-bnd.xmi. The ibm-web-bnd.xmi file needs to live in the same directory as web.xml (i.e. under WEB-INF).

web.xml – resource-ref

Flex Messaging WorkManagerwm/


Tip: If you use the application server toolkit (AST), that comes with WebSphere it provides decent editors that do all the hard work for you 🙂


So what’s next?

I plan to write a few more blog entries surronding WAS, these include:

  • Developer workflow – looking at how we develop against WAS when we don’t want to spend a bundle on IBM tooling. I will talk more about the AST here.
  • Single Sign-on (SSO) – increasing we are being asked about SSO with Flex, the most common configuration being SiteMinder and WAS. I have already put together a SSO example (not using SiteMinder) that proves the concept. I will blog this when Flex 2.0.1 is released. If you want to know more in the mean time drop me a line.

12 Responses to Deploying Flex on WebSphere Application Server

  1. Chad Upton says:

    Is this for WebSphere 4 or 5? From what I understand there is no solution for making it work on version 5, unless of course this is it!

  2. Bartosz Doszczak says:

    I’ve tried to deploy my flex app to Websphere 5.1 and it seems to me that RTMP does not require setting up Work Manager. Unfortunately, I was unable to setup a secure RTMP channel. When the client loaded over HTTPS a a consumer attempts to subscribe to a RTMPS destination it is timed out.I guess it has something to do with Websphere keystore and truststore but I am not sure how they should be set-up to cooperate with the flex client properly.I would be grateful for any help!Cheers,Bartek

  3. Chris says:

    Have you posted the Single Sign-On example yet ? I would be very interested in seeing it. Can it be done with an RTMP channel, persistent connection – not polling ? Thanks

  4. el.Fakir says:

    Hi there, I’m also interested to learn more on the SSO part. Here, we have a SiteMinder agent on IBM HTTP server, which communicate with a WebSphere 6.0 server, on which FDS 2.01 are running.I’ve seen that SSO relies on cookies, right? It also seems that, for each browser request, cookie value is updated. But, as we only have a single URL for our whole Flex application, how do we manage this cookie update? From Flex?…Also, is IBM LTPA with SiteMinder plugin a good idea? (which mean no more SiteMinder agent on IHS but some additional piece of code inside our application).Thanks!

  5. mohneesh says:

    Hi PeterThat was really helpful. From where can i get the Sample example for SSO?

  6. Randall Thomas says:

    Peter,I am really interested in SSO (Single Sign On) in Adobe Flex 2.01. Can you provide and example of recommendations best suited to impliment?Thanks

  7. Pradeep says:

    I read your plan to blog implementation of SSO with Flex (more specifically SiteMinder on WAS). We are required to do this for one of our and will be grateful if you can provide information.regards,Pradeep

  8. jayanth says:

    hithis is jayanth can any one please tell me how to configure my webservice on jndi and i am not using ejb or something else it is just a webservice actually my plan of having jndi is that i need to jndi lookup my service can any one help thanks in advance .and this article has been good

  9. Shilpa says:

    Did you ever do an implementation of SSO with Flex? If yes, where can I find it?Thanks

  10. Bartosz Doszczak says:

    Is there any place where the SSO sample can be found? Do you have any experience with SAML as SSO mechanism?Cheers,Bartek

  11. KK says:

    Hi,I am really interested in SSO (Single Sign On) in Adobe Flex using Siteminder. Can you please provide and example ?In our project we need to read attributes from Siteminder header for authorization. I inderstand we cannot read HTTP Headers from Flex, how can we achieve this?Thanks,KayKay

  12. Peter Martin says:

    Hi KayKay,I am unable to provide you with an example. Unless you are using RTMP Flex/DS is no different from any other web application. I wouldn’t expect you to do anything in Flex or Data Services. SiteMinder should provide a plugin for your app server, if you configure it up, it should work. I would try this first with an HTTP-based channel. If you need to use RTMP then you need to get the principal from the HTTP session and push it in to the RTMP session.CheersPeter.