Integrate Adobe Flex and JBOSS using BlazeDS – Part I

In this tutorial I will give you step by step instructions on how to integrate Adobe Flex and JBOSS using BlazeDS.
Although in this tutorial I am addressing BlazeDS, the steps in this tutorial should also apply to Adobe Flex LiveCycle Data Services. The only difference are the jars that you copy to your WEB-INF/lib directory. For those who want to integrate BlazeDS with Struts 2, the instructions in this tutorial should also be helpful.

In the Java Backend:

Step 1

Download blazeds.war from

Step 2

Unzip blazeds.war. Copy the files in WEB-INF/lib and WEB-INF/flex to your web project under the same path in your web app.

Step 3

Edit web.xml and add the following lines:

    <!-- Http Flex Session attribute and binding listener support -->

    <!-- MessageBroker Servlet -->


Step 4

Create a simple java class with a simple method that we will invoke from Adobe Flex:


import java.util.ArrayList;
import java.util.List;

 * This remote service is called using BlazeDS/LiveCycle DS from Flex
 * @author Armindo Cachada
public class RemoteService { 
  * I am not doing anything useful except to just show that I can be invoked remotely
  * from Adobe Flex using RemoteObject.
 public List<String> callMe() {
  System.out.println("I am being invoked!");
  List<String> result = new ArrayList<String>();
  result.add("Michael Jackson");
  result.add("Tina Turner");
  return result;

Step 5

Create a new destination in remoting-config.xml:

<destination id="remoteService" >

The source of the destination can be a fully qualified class name, a jndi reference or a spring bean. We will discuss that in a later post. For this example we just specify a class name.

The scope of the destination can be one of:

  • application – there is only one instance of the class for the entire application(i.e. global in atg, singleton in spring)
  • session – there is one instance per user session
  • request – for each http request a new instance of the class is created

In Adobe Flex:

Step 1

Create a new project in Adobe Flex. Please make sure that the Application Server type is set to none.
Why? Fair question to ask since most instructions say to do exactly the opposite. I found those instructions not really helpful in the case of JBOSS since they assume I can provide the directory containing the application after it is deployed to JBOSS. That works quite well for tomcat because it simply extracts the war file under webapps. The path is always the same. In the case of JBOSS the path to the application changes after each deployment…

Step 2

The only reason Adobe Flex asks you for the path to the root folder of your web application is so that it can provide two arguments to the flex compiler:

  • services – The path to the Adobe flex data services configuration file
  • context-root – The context root of your web application

After you create your web application add the following arguments to the flex compiler:

-services "/usr/java/eclipse/workspace/example6/resources/flex/services-config.xml" -context-root "/example6"

Step 3

Let’s create a very simple flex application that invokes the callMe() method in This method returns an ArrayList with a list of items:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="vertical" >
  import mx.collections.ArrayCollection;
  import mx.controls.Alert;
  import flash.utils.getQualifiedClassName;
   * Populates the data list using the results returned by callMe()
  private function populateList(event:ResultEvent):void {
   var result:ArrayCollection= ArrayCollection(event.result);
   singerList.dataProvider= result;
 <mx:RemoteObject id="myService" destination="remoteService" result="populateList(event)"/>
 <mx:List id="singerList" >
 <mx:Button click="myService.callMe();" label="Call Remote Function"  />

Step 4

Compile the flex app and copy all the generated swf/html/js to your jboss web app.

Step 5

Deploy the war file to JBOSS and test it under http://localhost:8080/example6

If you click in the “Call Remote Function” button you should see a list of results returned by the method callMe().

Download source code for JBOSS+Adobe Flex+BlazeDS project

Note that, in order to make the zip smaller, I didn’t include the BlazeDS jar files. You need to manually copy them to the lib directory before generating the war file.

Click here to read Part II

3 thoughts on “Integrate Adobe Flex and JBOSS using BlazeDS – Part I”

  1. Hello,

    i’m facing this error :

    [RPC Fault faultString=”[MessagingError message=’Destination ‘remoteService’ either does not exist or the destination has no channels defined (and the application does not define any default channels.)’]” faultCode=”InvokeFailed” faultDetail=”Couldn’t establish a connection to ‘remoteService'”]

    Any help please ??

  2. Do you happen to have done this using JBoss 7? The structure is quite different and not sure how or where to put all the BlazeDS files.

Leave a Reply

Your email address will not be published. Required fields are marked *