Using Flex, BlazeDS, and Java Together - A Simple Tutorial


When you want to directly use Java classes to provide data to a Flex application you need to add some additional plumbing that enables Flex to "talk with" the Java classes. Flex comes ready to rock with ColdFusion Components, but doesn't have everything it needs to communicate directly with Java classes exposed by a J2EE or servlet container such as Tomcat.

I know that Flex can use either web services or HTTP services to communicate with a Java servlet or JSP page, but what I want to be able to do is leverage my Java classes directly to provide data to Flex, similar to how a ColdFusion Component can be called using the <mx:RemoteObject> tag and return complex data to the Flex application.

Adobe offers 3 different technologies (reference 1) that have different costs and provide different services (see references 2 and 3) for integrating Flex with Java.

BlazeDS is "the server-based Java remoting and web messaging technology that enables developers to easily connect to back-end distributed data..." (reference 4). As I understand it BlazeDS is the free open-source plumbing we need to install in our server to allow Flex to communicate with Java classes.

Since I recently changed jobs from a company that used Flex and ColdFusion to a company using Java to create web applications, I need to learn how to integrate Flex and Java. I won't get into how much I miss creating web applications using ColdFusion 8 (it's alot). I hope to eventually show my new co-workers the benefits of using Flex on the front-end of our web applications. To do that I need to get Flex working with Java on the back end.

This is the first in what I hope will be a series of posts showing how to use Java on the back end with Flex on the front end and BlazeDS providing the plumbing to enable Flex and Java to work together. I'm starting off very easy with a "Hello World" example.


I spend much of a Sunday morning just trying to find a good example of integrating Flex and Java using BlazeDS. The BlazeDS web site (reference 5) was not the most helpful. First they expect you to download a complete turn-key system that includes a version of Tomcat, the BlazeDS application, and several examples. They then explain how to run the examples but only if you've downloaded their turn-key system. I already have Tomcat running on my Java web application development server so I really just wanted to learn how to integrate BlazeDS into my existing Flex Builder 3 and Tomat server development environment.

I would have happily studied their example code to try to figure out how to use BlazeDS but after searching throughout the BlazeDS web site I could not find a download just for the example applications source code.

After several hours of trial-and-error, I think I've come up with the steps to get Flex, BlazeDS, and Java working together. So this blog article will hopefully help you (and me) learn how to get Flex, BlazeDS, and Java working together. A demo of the example application you'll build using the instructions below can be viewed here.

Steps for Using Flex With Java

1. Note my development system setup. If your system setup is different then you'll need to adjust these instructions.

a. Windows XP

b. Tomat 6.0 installed in C:\Program Files\Apache Software Foundation\Tomcat 6.0\ referred to as [tomcat-home]

c. Tomat server running on port 8080

d. Flex Builder 3

2. These instructions assume you know how to do the following:

a. Create Java classes

b. Use Flex Builder 3

c. Stop and start Tomcat

3. Download BlazeDS (these instructions are as of June 22, 2008)


b. Download the BlazeDS binary distribution

 i. Save the .zip file to your computer

ii. There are two files in the zip – blazeds.war and blazeds-bin-readme.html

iii. Extract blazeds.war to your [tomcat-home]\webapps directory

c. Stop Tomcat if it's running and then start Tomcat

d. In Windows Explorer navigate to the folder [tomcat-home]\webapps

 i. You should now have a folder named blaseds

ii. Under blazeds is a folder named web-inf

 iii. Under web-inf are several folders, one called classes is where we will put our Java classes so that our Flex application may use them.

iv. Under the folder flex is an xml file named remoting-config where we will put an XML node that tells our Flex application how to connect to the Java class

4. Using a Java IDE (for example Eclipse or Flex Builder 3 with the Java plug-in) create the following Java source file named

package example;

public class HelloWorld {

public HelloWorld() {


public String getHelloWorld() {

return "Hello From Java!";



Compile the Java source file into a class file (HelloWorld.class). Since our source file specified a package of example, our class file should be under a folder named example.

a. Copy the example folder to [tomcat-home]\webapps\blazeds\WEB-INF\classes

5.  Add the following node to [tomcat-home]\ webapps\blazeds\WEB-INF\flex\remoting-config.xml right after the closing </default-channels> node and before the closing </service> node. Note the values for id attribute and the value for the source tag (the complete path and name of our Java class).

<destination id="helloworld">




<adapter ref="java-object"/>


6. Stop Tomcat if its running and start Tomcat

7. Create a new Flex Project named HelloWorld

a. In the New Flex Project wizard select J2EE as the Application Server type (see the very limited instructions here for some help)

b. Make sure Use remote object access service is checked

c. Click next

d. On the configure J2EE server uncheck use default location for local LiveCyle Data Services server

e. Specify the following values for root folder, root URL, and context root

 i. Root folder: C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\blazeds

                                                       ii. Root URL: http://localhost:8080/blazeds

                                                      iii. Context root: /blazeds

f.  Click on the Validate Configuration button – should get the message "The web root folder and root URL are valid."

g. Click Next and then click Finish

8. In your HelloWorld.mxml create the following source between the <mx:Application> </mx:Application> tags





import mx.utils.ObjectUtil;

import mx.controls.Alert;

import mx.utils.StringUtil;

private function resultHandler(event:ResultEvent):void


//used for debugging - shows details about result

//returned by the Java class method ObjectUtil.toString(event.result) );


private function faultHandler(event:FaultEvent):void

{ ObjectUtil.toString(event.fault) );




<mx:RemoteObject id="ro" destination="helloworld"




<mx:Panel x="10" y="10" width="440" height="200" layout="vertical" title="Test Flex 3 Using Java" borderColor="#008040" fontFamily="Arial" fontWeight="bold" fontSize="13">

<mx:Text text="Click The Button To Test Getting Data Into Flex From A Java Class" fontWeight="bold" width="250"/>

<mx:Spacer height="20"/>

<mx:Button label="Get Hello World!" click="ro.getHelloWorld()"/>


9. Run the Flex HelloWorld application. You should see an HTML file with a Flex panel and a Get Hello World! button. Click on the button and a Flex Alert component should appear with the words "Hello from Java!".

10. Note in the mx:RemoteObject tag the value for destination matches the id attribute value and our source matches the value for the source tag in our destination node in the remote-config.xml file.

Trouble-shooting Tips

If you change the HelloWorld Java file then you'll need to copy the new class file into the [tomcat-home]\webapps\blazeds\WEB-INF\classes folder in the correct package. Then you'll have to stop and restart Tomcat.

If you change the remote-config.xml file, you'll need to stop and restart Tomcat. You may also need to rebuild your Flex application before running it again.


How easily Flex works with ColdFusion Components (CFCs) is just another reason I miss ColdFusion. But my new company uses Java to develop their web applications and they are not going to change to ColdFusion. But I hope that eventually we will be able to use Flex on the front end and Java on the back end where it makes sense. But first I've got to get smart on how to integrate Flex and Java. So I've got alot of learning and trial and error. I'll keep you posted in this series of blog entries.

Up next - sending information from Flex to a Java class.


  1. LiveCycle Developer Center
  2. LiveCycle ES vs LiveCycle DS vs BlazeDS - clearing up the confusion
  3. BlazeDS and LCDS Feature difference
  4. BlazeDS Overview
  5. BlazeDS
  6. Creating Flex Builder Projects that Use Server Technologies


Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
hi! i tried to follow your instructions.. the steps are very clear.. (thanks for that ^^).. but then.. when i clicked the get Hello World! button.. i got this error message..

errorID = 0
faultCode = "InvokeFailed"
faultDetail = "Couldn't establish a connection to 'helloworld'"
faultString = "[MessagingError message='Destination 'helloworld' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']"
message = "faultCode:InvokeFailed faultString:'[MessagingError message='Destination 'helloworld' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']' faultDetail:'Couldn't establish a connection to 'helloworld''"
name = "Error"
rootCause = (null)

**help! i'm really lost.. dunno what to do =(
# Posted By Jen Sze | 6/23/08 2:18 AM
Jen - I got that exact same error when I was setting this example up. Here are some trouble-shooting tips to try:

1. Verify that HelloWorld.class is in the [tomcat-home]\webapps\blazeds\WEB-INF\classes folder

2. Double check that you've entered the correct node data in remote-config.xml

3. Restart Tomcat

4. Ensure in the mxml file that in the mx:RemoteObject tag source = "example.HelloWorld" is there

5. Check your project properties for the correct root folder, root url, and context root (click the test configuration button to verify them)

6. Do a complete clean of your Flex project

After doing the above try re-running the flex project.

Good luck, Bruce
# Posted By Bruce | 6/23/08 5:04 AM
yey!!!! it works it works!

but i dont know what is the problem.. i just followed your trouble shooting tips.. and it works.. O_O.. haha.. anywayz.. thank you thank you!!!

your post really helped me a lot.. i tried different site before and i got lost somewhere.. but your post is really complete and really step by step.. ^^

i am working on a project, using flex as front end and java as the backend.. i tried webservice before (with the wsdl stuff).. but i think I read somewhere that BlazeDS is better right? hehehe.... i guess i will try BlazeDS for now.. see how far I could get from there.. =)

go go go! ^^
# Posted By Jen Sze | 6/23/08 6:11 AM
Jen - glad you got it to work.

BlazeDS is supposed to be the fastest way for Flex to communicate with Java on the backend.

I'll be doing a series of blog posts on using Flex and Java with BlazeDS providing the plumbing between the two. But I'm just learning how to use BlazeDS myself, so keep us posted on your experience with using Flex and Java.
# Posted By Bruce | 6/23/08 6:17 AM
yup yup! thanks!

sure sure.. i'm also learning/exploring the BlazeDS right now.. hehe.. trying to connect to DB now.. hehe.. hope it works.. :D

i will surely keep you posted about my experience.. hehe.. thanks =)

go go go! ^^ will visit your site very often.. :D
# Posted By Jen Sze | 6/23/08 6:28 AM
hi bruce!

i was able to succesfully get data from my DB! yey! improving! (more to go~)

i guess if it not for your blog article.. i would still be stuck in figuring out how to make that BlazeDS works.. hehe. =D

i just realized that it's quite the same as the WebService.. well. ofcourse, now I have to use RemoteObject instead of WebService and method instead of operation.. aside from that I guess everything is quite the same.

I guess there's still lot to learn as I work on my project.. but this is already a good start! Thanks :D

- Jen
# Posted By Jen Sze | 6/23/08 7:25 AM
I have just read your article and found that you have really done a good job by giving step by step process of Integration.

Keep doing great work
# Posted By Jack | 6/23/08 10:14 AM
Bruce, I experienced the same frustrations with BlazeDS and Java. So much so that I ditched the effort entirely and stuck with web services. I think the lack of documentation and setup complexity really hurts BlazeDS.

One thing that further guided our decision to use web services was the inherent debuggability and interoperability of the textual XML format. AMF may be touted as more performant but properly designed services should never be so fragile that they depend upon a binary format to achieve responsiveness. In addition, though AMF is now an open protocol there are not a huge number of implementations. Therefore, you are effectively in a case of vendor lock-in.

Either way, thank you for taking the time to write this tutorial for the greater good of us all.
# Posted By Rex Sheridan | 6/23/08 10:42 AM
Hi Bruce,

I agree with you that AMF is much better option if we have to transfer lots of data. But there is not benchmark available like if you have 50 kb of data to be tranferes use AMF.

some thougths from your side
# Posted By Jack | 6/24/08 4:55 AM

For small amounts of data I don't think there would be much difference between AMF and XML. However, my goal here is to see if BlazeDS will enable me to put a Flex front end on some Java web applications that return several hundred objects to a JavaServer Page where the objects are displayed using a mixture of JavaScript and Struts2 tags.

I think a Flex front end (based on my previous job) would provide a much nicer and easier to maintain user interface. But first I need to verify that BlazeDS will provide the plumbing between Flex and Java as the Java back end is not going to change.
# Posted By Bruce | 6/24/08 5:28 AM
I don't understand why Adobe doesn't offer BlazeDS examples separately (without Tomcat). After being unlucky with finding a simple "Hello World" with BlazeDS, it killed half of my day to write a simple service. I wish I tried it after your post. This series of your posts should be at least linked from Adobe Blaze DS site.

Thanks for sharing, I am sure it will save a day for many developers.
# Posted By Djam | 6/25/08 8:55 AM
THank you so much for the tutorial. I did everything right but in Flex Builder didn't provide Blazeads location while creating flex project. That one took my whole day but after doing google (which I didn't because I was trying too hard to do it in their built in tomcat which was my fault) found your note and everything looks good (now hibernate needs to work heheh)

sample apps come with blazeads is good start point to understand how everything
# Posted By NN | 7/10/08 5:31 PM
I got hibernate running with Blazeads on tomcat. Just copy all the hibernate files under classes folder of "webapps\blazeds\WEB-INF\classes\". (your package name start under classes folder as you know if none you will have java classes)

hibernate files are "hibernate.cfg.xml" and "<name of class-mostly on table name>.hbm.xml".

also make sure you copy all the hibernate jar files in "webapps\blazeds\WEB-INF\lib" directory. Make sure you have mysql and jdbc driver in place (if you have existing app connecting to mysql using tomcat you don't have to do anything apart from previous steps)
# Posted By NN | 7/10/08 5:53 PM
Great job!
You are great!
# Posted By Y.Boy | 7/21/08 8:50 PM
So well explained Bruce. I just got this example working on JRun. Thanks
# Posted By Bar | 7/22/08 7:05 AM
Hi there,
I had a problem when a extract the 2 files from BlazeDS binary distribution. I extract this file, blazeds.war to C:\Archivos de programa\Apache Software Foundation\Tomcat 6.0\webapps, i restarted Apache but there's not a blazeds folder in the directory, only blazeds.war file.
Any suggestion? thk
# Posted By matias | 7/25/08 5:12 AM
the problem is gone!
Nice work Bruce!!
keep on this
# Posted By matias | 7/25/08 5:20 AM
Thanks for the lucid tutorial - I got everything to work using your tutorial (I've deployed blazeds.war on a remote server running GlassFish).

A couple of things that are confusing to me though - when creating a new Flex Project using J2EE server as the server type, the wizard asks me for a 'root folder' (as you've mentioned here.) I got around this by mounting my blazeds application folder on the remote server using samba, but does this mean that any application I develop using flex will rest on the same server as my J2EE server? What if I just want to make a html and swf that talk to the remote java object? Your example here runs fine..but when I move the html and swf to my local machine and run it, it gives me a bunch of errors. I couldn't find a configuration file with the project that would allow me to change the remote blazeds server url.

Hope I'm making sense. Thanks much in advance!
# Posted By Vineet Bansal | 8/4/08 2:03 PM
Thanks for the instructions...They are very well explained...nice work.

I am facing this problem...I tryed to set a variable called 'data' in the . In my processSayHello function inside my mxml I have some this:


now when I try to print this text (which it should print moussa), it prints null..

any suggestions?

Thanks in advance
# Posted By Moussa | 8/8/08 6:11 AM
'Destination 'helloworld' either does not exist or the destination has no channels defined (and the application does not define any default channels.'

I get the same (or very similar) error when trying to access a Java class using the Flex RemoteObject class. I have the destination "helloworld" defined in remoting-config.xml on the server. Is there something I need to do to tell the Flex client about that file? I know I can pass the "-services c:\path-to\services-config.xml" so that it knows about services, but how do I tell it about Remote objects?

My "RemoteObject" has the destination entered correctly and the "source" is also set.

Any ideas?
# Posted By codecraig | 8/13/08 4:01 AM
Got it.

My services-config.xml was not including "remoting-config.xml".

<?xml version="1.0" encoding="UTF-8"?>

<service-include file-path="messaging-config.xml" />
<service-include file-path="data-management-config.xml" />
<service-include file-path="remoting-config.xml" />
# Posted By codecraig | 8/13/08 4:12 AM
Hi... all steps are easy to follow . but at step 7 when i clicked the Validate Configuration button instead of getting the message "The web root folder and root URL are valid"
I got
"Cannot access the web server. The server may not be running, or the web root folder or root URL may be invalid."
# Posted By Anu George | 8/19/08 2:26 AM

Your example looks really cool and really helped me in learning the Flex integration with Blazeds and Java.
But it would be great if you help me out for the below scenario.
My Blazeds server is located in remote machine. Say for example,
And i have my Flex installed in other machine. If i want to include the above mentioned URL in the FlexAPP to retrieve the method of the class located in Blazeds server, how can I?
ie, Flex code talking with the Blazeds located in other machine.
Thanks in Advance
# Posted By Sathish | 8/22/08 4:29 AM
i have problam when i followed that 9 steps to integrate flex with java ,following error message coming

messageAgents = (Array)#7
[0] (mx.rpc::AsyncRequest)#8
authenticated = false
autoConnect = true
channelSet = (mx.messaging::ChannelSet)#4
clientId = (null)
connected = false
defaultHeaders = (null)
destination = "helloworld"
id = "39802F25-7BA6-1D57-42CC-04A5991AA383"
reconnectAttempts = 0
reconnectInterval = 0
requestTimeout = -1
subtopic = ""
connected = false
connectTimeout = -1
enableSmallMessages = true
endpoint = "http://localhost:8080/blazeds/messagebroker/amf&qu...;;
failoverURIs = (Array)#9
id = "my-amf"
mpiEnabled = false
netConnection = (
client = (mx.messaging.channels::AMFChannel)#2
connected = false
objectEncoding = 3
proxyType = "none"
uri = "http://localhost:8080/blazeds/messagebroker/amf&qu...;;
piggybackingEnabled = false
polling = false
pollingEnabled = true
pollingInterval = 3000
protocol = "http"
reconnecting = false
recordMessageSizes = false
recordMessageTimes = false
requestTimeout = -1

plz tell abt this error i am waiting for your reply
# Posted By raja | 8/27/08 7:57 AM
Bruce, you rule dude.
Until you, nobody has taken a moment to properly explain, really step by step, this thing. All the other explanations miss steps or make it much more complicated than it acually is. I also spent one morning messing around, and your tutorial help me to achieve it in 10 mins!

Thanks very much, if anytime, in this or other life, i'll meet you, remember me to invite you to some beers!!! :)
# Posted By efialto | 8/27/08 8:11 AM
raja - I think you may have missed something when following step 7. Recommend you start over at 5.
# Posted By Bruce | 8/27/08 8:38 AM
raja - also see my trouble-shooting tips above in one of the comments.
# Posted By Bruce | 8/27/08 8:47 AM
Hi Bruce,

I am trying to set up blazeDS on a remote server, and I am not sure how to configure the compiler (-services) and server settings (root folder) to make it work. I keep getting errors about invalid root folder, or the web server cannot be connected. I would appreciate any pointers you can give me. Thanks a lot!

# Posted By Christina | 8/27/08 2:05 PM
Thanks for the excellent tutorial :) A whole new world just opened up!
# Posted By Johan Strydom | 8/30/08 12:17 AM
its great article..u made blazeds simple:)
# Posted By Mayur | 8/30/08 7:41 AM
Hi erveryone,

To resolve the problem of getting "Cannot access the web server. The server may not be running, or the web root folder or root URL may be invalid." you need to install this version of Apache Tomcat :
and the problem will be gone.

# Posted By Matias | 9/2/08 10:49 PM
i want call jsp using http service using flex appliaction

but i want know about where to put jsp in which folder?

is it jsp in WEB_INF of blazeds or other folder? or

any steps is neccesary plz reply to me?
# Posted By raja | 9/3/08 9:39 PM
Hi bruce,

Finally a nice tutorial. Seems good and working good so far.. but i am having a little problem in step 7-f... when i press the button.. it says
'Cannot access the web server. The server may not be running, or the web root folder or root URL may be invalid.'
however i have checked in browser, 'http://localhost:8080' is working fine
can you tel me what can be wrong?
i wil also try continue so that it might work...
# Posted By Uz | 9/23/08 3:15 AM
in 4-a by 'Copy the example folder' which example folder do you actually mean.. is it the one that has just one 'HelloWorld.class' file in it?
# Posted By Uz | 9/23/08 3:31 AM
Its done :)
thanks alottttt for your tutorial...
i just copied the rong example folder...
no need to reply now
thanks again
leme try this on my actual application now
hope that works .. coz m stuck on it for about a month now :(
# Posted By Uz | 9/23/08 4:46 AM
This is Kartik and a newbie flex aspirant.
I am making a flex application with J2EE(Glassfish server) + Flex .
I was trying to explore Blaze DS but the problem is that i am unable to deploy in Glassfish server.
Can u please give me some insights as to how to install Blaze DS on a glassfish server or whether Glassfish doesn't support Blaze DS.
Also please provide me with some material wrt Blaze DS.

# Posted By kartik | 10/1/08 12:10 PM
Hi guys,
I have been struggling last couple of days to get blazeds for with jboss. I did follow the steps in this article but like some of you have faced I am not able to successfully validate the flex server "Cannot access the web server. The server root folder or root URL may be invalid". Could you please direct me to solve this problem.
Another question was, if it is any different with a JBOSS App Server and how do you run the HelloWorld.mxml.
# Posted By praman | 10/7/08 2:53 PM
Thanks for information this is really nice concept to learn...
i want to learn how to communicate database from the flex ?
# Posted By priya | 10/13/08 12:05 AM
its great.....thanks bro..
# Posted By Ambuj | 10/22/08 4:02 AM
Hats off to you Bruce...
this material is indeed of great learning...
Since Monday I've been trying to find out how to set-up a sample project in such an environment and obviously neither of BlazeDS docs nor any other help could be found in setting up a project over an existing J2ee web-server.
cheers to u... I could run my first sample without much fuss.
As it is evident that you've been into blazeDS for the past 4 months n you have done a lot, please have your valuable ideas on the implementations through any of J2ee architecture, preferably Struts.
# Posted By letitbe | 10/22/08 7:56 AM
I am getting the below mentioned error on trying the example. Any thoughts?
errorID = 0
faultCode = "Server.ResourceUnavailable"
faultDetail = "Type 'HelloWorld' not found."
faultString = "Cannot create class of type 'HelloWorld'."
message = "faultCode:Server.ResourceUnavailable faultString:'Cannot create class of type 'HelloWorld'.' faultDetail:'Type 'HelloWorld' not found.'"
name = "Error"
rootCause = (null)
# Posted By Maninder | 10/25/08 4:01 PM
the article it was really helpful. For me it worked.
Just a little question, is it posible to acces this way the beans exposed in an Enterprise Aplication (an .ear) in Glassfish?
Thank you very much,,
# Posted By David Vacas | 11/4/08 4:10 AM
Hi I am Flash developer and doing somewhat good in Flex,
but I am new to Java when I tried your above example I got all
the things placed proper and could run the application.
But I got an following error whie cliked on the "Get Hello World!" button.

ERROR Details are as follows:

errorID = 0
faultCode = "Server.Processing"
faultDetail = (null)
faultString = "Bad version number in .class file (unable to load class example.HelloWorld)"
message = "faultCode:Server.Processing faultString:'Bad version number in .class file (unable to load class example.HelloWorld)' faultDetail:'null'"
name = "Error"
rootCause = (Object)#1
cause = (null)
localizedMessage = "Bad version number in .class file (unable to load class example.HelloWorld)"
message = "Bad version number in .class file (unable to load class example.HelloWorld)"

I tried doing following.
I was having JDK 1.6 and JRE 1.6
I uninstalled Jdk and installed the previous version jdk 1.5
I unistalled Apache Tomcat 6.0.18 and reinstalled
And repeated above steps again

I tried the troubleshooting tips given above, still it gives errors.
But still I am getting the same error can you help me resolving this.

Iresh SA
# Posted By Iresh | 11/12/08 4:29 AM
Iresh - try compliling HelloWorld source file to a new class file. Then try just running HelloWorld.
# Posted By Bruce | 11/12/08 8:15 AM
One more handy thingy
Instead of the modifications to blazeds in tomcat. You can do these in the Flex Builder project themself.

Overall nice that you shared this info. At this moment you are my guru djie. ;)
# Posted By amackguy | 11/22/08 10:29 AM
Thanks fr this info.. I am learning Flex and I want to use Java on the server side and this info is great! I do have a question though..Once I create an application, how do I go about finding a service provider that has BlazeDS?
# Posted By Pedro | 11/25/08 10:45 PM
Hi Bruce
Your article is excellent, its help me a lot. You cover everything from top to bottom also most important thing Trouble-shooting (most authors do not care then you can see a long list of comments) .I just follow your instruction; create my own java class and its works like charm.
Thanks Bruce
help me a lot. Also i really like your style you cover ev
# Posted By Lincoln | 11/27/08 5:43 PM
Hi Bruce thanks a ton for this article.. well written and easy to find using google
# Posted By Colin | 12/10/08 7:45 AM
Has anyone managed to run this as an Adobe Air project?
Mine reports back "Hello from Java" just like it should when built as a web application(which runs in Flash Player). But when I build it as a desktop application (to run in Adobe Air), I get the following error after clicking "Get Hello World!":

errorID = 0
faultCode = "Client.Error.MessageSend"
faultDetail = "Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://ain.swf/blazeds/messagebroker/amf'"
faultString = "Send failed"
message = "faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://ain.swf/blazeds/messagebroker/amf''"
name = "Error"
rootCause = (
bubbles = false
cancelable = false
channel = (mx.messaging.channels::AMFChannel)#2
authenticated = false
channelSets = (Array)#3
[0] (mx.messaging::ChannelSet)#4
authenticated = false
channelIds = (Array)#5
[0] "my-amf"
channels = (Array)#6
[0] (mx.messaging.channels::AMFChannel)#2
clustered = false
connected = false
currentChannel = (mx.messaging.channels::AMFChannel)#2
initialDestinationId = (null)
messageAgents = (Array)#7
[0] (mx.rpc::AsyncRequest)#8
authenticated = false
autoConnect = true
channelSet = (mx.messaging::ChannelSet)#4
clientId = (null)
connected = false
defaultHeaders = (null)
destination = "helloworld"
id = "E363D005-8B85-50F3-8143-222B15E86D30"
reconnectAttempts = 0
reconnectInterval = 0
requestTimeout = -1
subtopic = ""
connected = false
connectTimeout = -1
enableSmallMessages = true
endpoint = "http://ain.swf/blazeds/messagebroker/amf"" target="_blank">http://ain.swf/blazeds/messagebroker/amf";
failoverURIs = (Array)#9
id = "my-amf"
mpiEnabled = false
netConnection = (
client = (mx.messaging.channels::AMFChannel)#2
connected = false
objectEncoding = 3
proxyType = "none"
uri = "http://ain.swf/blazeds/messagebroker/amf"" target="_blank">http://ain.swf/blazeds/messagebroker/amf";
piggybackingEnabled = false
polling = false
pollingEnabled = true
pollingInterval = 3000
protocol = "http"
reconnecting = false
recordMessageSizes = false
recordMessageTimes = false
requestTimeout = -1
uri = "http://{}:{server.port}/blazeds/messagebroker/amf"
url = "http://{}:{server.port}/blazeds/messagebroker/amf"
useSmallMessages = false
channelId = "my-amf"
connected = false
currentTarget = (mx.messaging.channels::AMFChannel)#2
eventPhase = 2
faultCode = "Channel.Connect.Failed"
faultDetail = "NetConnection.Call.Failed: HTTP: Failed: url: 'http://ain.swf/blazeds/messagebroker/amf'"
faultString = "error"
reconnecting = false
rejected = false
rootCause = (Object)#11
code = "NetConnection.Call.Failed"
description = "HTTP: Failed"
details = "http://ain.swf/blazeds/messagebroker/amf"" target="_blank">http://ain.swf/blazeds/messagebroker/amf";
level = "error"
target = (mx.messaging.channels::AMFChannel)#2
type = "channelFault"

The only clue that really stands out to me is the missing letter in all of the URLs right after 'http://'. Any help in proceeding with AIR would be appreciated.

Thanks for the clear, well-documented article,
# Posted By JackD | 12/10/08 2:02 PM
Your article is very informative, thanks for such an article.
I have a doubt, as to how to this integration in case the server is not on your working system. i.e you need to deploy blazeds on a server system.

thanks in advance
# Posted By Harsha galla | 12/18/08 3:31 AM
This is a very help ful article. All the steps were clear and it worked in one
shot. I am also now planing to develop an application with java backend
and flex as front end. Waiting for your next blogs related to this.

Appreciate your effort and time for such a nice and clear article.
# Posted By Santhosh | 12/19/08 1:22 AM
Hello Bruce,

Your material helped me a lot. Thanks!
I am trying to connect database(MySQL) with Java and Flex. I have a method in java class returning List, now want to save that list in ArrayCollection.

Please suggest me how I have to fetch List(of objects) from Java Class into .mxml file.
# Posted By komal | 12/24/08 12:23 AM

Read through the entire series I wrote on using Java, BlazeDS, and Flex. The last article using Java to get information from a database and return an ArrayList to Flex.

See: /blog/index.cfm/FX

# Posted By Bruce | 12/27/08 9:48 PM
Hey Bruce
I'd like to thank you for your information you put on your site. It sure helped me to start with passing objects between java and flex!
I have a little remark though ;)
I noticed you have in your <mx:RemoteObject> a property source="example.HelloWorld" but this is unnecessary as it finds this information in the remoting-config.xml.
Just my 5 cents ;)
# Posted By Jan | 12/28/08 8:26 AM
Jan - you're correct about the source attribute not being necessary in the mx:RemoteObject tag. I point that out in the next blog article I wrote in this series on using Flex, Java, and BlazeDS.
# Posted By Bruce | 12/28/08 10:19 AM
hey bruce,
I have a typical scenario. I have an already existing java project(say Sample). Now this is deployed in tomcat. I am developing an UI using flex for the homepage of this project. I include the flex nature by right clicking the java project(Sample) and got sample.mxml created. Now the problem is
my tomcat is installed in C:/Porgram Files/Apache Software foundation and the blazeds i downloaded is extracted to the tomcat_home/webapps folder. But my source code for the project Sample is in C:/Sample and the output folder is also within the same folder(C:/Sample/Webapps). Whenever i compile the java project the output goes to this folder by default. I need to use some existing java classes and methods to get the data for the home page of this flex application. But by default my flex application looks for the class files in tomcat_home/webapps/blazeds/web-inf/classes folder. How do i configure my flex application to make use of the java classes that are already there deplyed in the tomcat server.

I tried changing the root of the flex server , url and context to my project(Sample/webapps) but it could not validate the configurations. Please let me know how to configure this scenario.

# Posted By sunil | 1/18/09 5:37 PM
Hi Bruce - I'm just getting started with Flex/BlazeDS. I tried your example as well as a similar one from the BlazeDS example but a similar error to that of Jen's earlier post. I'm compiling the file in eclipse and copying the class file to C:\Tomcat\jakarta-tomcat-5.0.28\webapps\blazeds\WEB-INF\classes. I have the remote-config setup like you mentioned. I have the service-config referencing my-amf:
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://localhost:8080/blazeds/messagebroker/amf&qu...;; class="flex.messaging.endpoints.AMFEndpoint"/>

I have the mxml file like you mentioned and compiled. I'm not using Flex Builder. Would really appreciate your help and/or any other person. Thx !
# Posted By newbie | 1/21/09 6:50 PM
Thanks you for tutor.
# Posted By Yuriy | 1/31/09 5:39 AM
Dear Bruce,

Thanks for this great tutorial! I did it too!
By the way do you have some advices to handle session in BlazeDS (idea is to perform a login, logout, etc)
Thank you. Your comments will be highly appreciated.
# Posted By Crystal Lake | 3/13/09 3:01 AM
Dear Matias,

I am also getting the same "Cannot access the web server. The server may not be running, or the web root folder or root URL may be invalid." error, and I also have installed " apache-tomcat-6.0.18, the version of tomcat. so please please please help me. What should I do to get it work correctly.
Please help me out.
# Posted By Amit giri | 3/15/09 5:30 AM
Dear Bruce,

Can you please help me out, I have been stucked.
Please please help me out.

Thanx in advance.

Amit Giri
# Posted By Amit giri | 3/18/09 9:17 PM
Hi Bruce !! Thank you so much for an excellent tutorial for Flex/Java Integration..It is so clear and understandable withut any missing piece of information. This is the best among many Flex/Java tutorials found on the Web..Excellent!!
# Posted By Swathi | 3/25/09 9:59 AM
Amit giri, could you resolve it?
# Posted By matias | 4/28/09 9:49 PM
Dear Bruce,
i got some nasty errors when i followed your instructions.
I downloaded the blazeDs.war from the site you recommended.
I am using flex builder 3.
I did the following to create a project:
File->New->FlexProject.. a pop-up askes me to
Project name: HelloFlexFromJava
Project location is the default:C:\Documents and Settings\Administrator\My Documents\Flex Builder 3
Application Type: Web Application(runs in Flash Player)
Application server type:J2EE
selected the Useremote object access service & Live Cycle Data Services
Selected Create combined Java/Flex project using WTP.....
Next Button is clicked and leads me to:
J2EE Settings:
Target runtime: Apache Tomcat v6.0
Context root:HelloFlexFromJava
Content Folder:WebContent
Flex War file:C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.18\webapps\blazeds.war
Other options are as default
Then i click Finish.
The Directory structure in Flex Navigator is as:

The above is the flex navigator structure.

However i tired two ways:
a) Since i am asked to show the flex war file, in that case i used blazeDs.war file as i had found in a blog to use it.
b)Since in your tutorial you have asked to extract the blazeDS war file.
I did everything upto my best knowledge.
I get those hasty busty nasty errors as posted by:Jen Sze

Please help me,i come from the back-ground of using wicket and i want to try my fingers in Flex
# Posted By Robin | 5/26/09 12:21 AM
Great tutorial on BlazeDS. To get to BlazeDS to run on JBOSS it is slightly more difficult. For those who are struggling, the following post will be helpful:
# Posted By Armindo Cahcada | 7/19/09 4:49 PM
Hello folks, well i am a little confused about the use of Flex and java, this is my problem: My java application must read two .zip files from an online server. These classes will load and parse the data in a Thread and perform certain actions depending on such info. The problem occurs when my flex application calls the java method that queries such data. I need to WAIT until the loading has finished. Any ideas?
Another doubt is if the Java classes are being compiled and transformed into some form of ActionScript classes.
Maybe I'm lost in space, so please I need a light in the darkness, thank you.
# Posted By Christian | 8/21/09 10:10 AM
Hello Bruce, Thanks for the easy-to-understand tutorial. Please let us know how to integrate Spring and Hibernate with Flex.

Appreciate your efforts.

# Posted By Sudhir | 9/12/09 8:25 PM
Great! I was struggling to get this working for 2 days and your tutorial did this in less than 2 hours! Thank you very much!
# Posted By Subbu | 10/5/09 5:41 PM
Hi there,

thanks for posting very good tutorial about flex-java project. After done with everything I got following error.

errorID = 0
faultCode = "Server.ResourceUnavailable"
faultDetail = "Method 'getHelloWorld' not found."
faultString = "Cannot invoke method 'getHelloWorld'."
message = "faultCode:Server.ResourceUnavailable faultString:'Cannot invoke method 'getHelloWorld'.' faultDetail:'Method 'getHelloWorld' not found.'"
name = "Error"
rootCause = (null)

I follow the your previous comment but still I haven't solve the issue. and can you please send me the blazeds\WEB-INF\service-config.xml and
# Posted By Kartik | 10/12/09 6:05 PM
Kartik - Go over the steps where you create the class, compile it, and copy it to the correct location. Everything is case sensitive so check to ensure you've used upper and lower case letters correctly. Check to ensure you've made the correct entries in the remoting-config.xml file.

# Posted By Bruce | 10/12/09 7:48 PM
Bruce, thanks a lot
you saved my day.
# Posted By Kham | 10/20/09 3:12 AM
Hey bruce,

You are awsome man,.. as im new to flex. since 3 days am strugling to
execute a sample program.... luckily i found this blog vch is very help ful,.
and am able to run the program ..
thanku very much,,,,,... going foraward i want to develop some more
complicated examples,.. for vch i need your help,..
once again thanku verymuch,....
# Posted By chaitu | 11/6/09 9:21 AM
Thank you very much for your excellent tutorial. I tried the turnkey dist, but didn't understand where to find and save which files. Now I got a glimpse of an idea and good hope to understand the structure further.

I've run into troubles at step #5, but changing the write/read rights for the blazeds folder let me succsessfully validate the server. Usually only users with administrator rights might write in the program folder. (I don't worry about security issues, because I don't intend to use that server in the wild/web - others may find a better solution.)

Thanks again for that great tutorial, I'll recoment it to my fellow student :-)
# Posted By pxa | 11/9/09 11:52 AM
Thanks for this tutorial. this is very useful for me to learn blazeDS with Flex.
i followed your instruction step by step everything is fine but while running the application it shows the following error.

content = (null)
errorID = 0
faultCode = "Server.ResourceUnavailable"
faultDetail = "Type 'example.HelloWorld' not found."
faultString = "Cannot create class of type 'example.HelloWorld'."
message = "faultCode:Server.ResourceUnavailable faultString:'Cannot create class of type 'example.HelloWorld'.' faultDetail:'Type 'example.HelloWorld' not found.'"
name = "Error"
rootCause = (null)

please help me to solve this error.

- Bala
# Posted By Bala | 12/11/09 4:27 AM

Thanks for the step by step instruction.
I tried to use remote object and struggle for 2days but after going through your blog i test success. Many thanks to you and keep writing.

# Posted By Aniket | 1/14/10 1:57 AM
Hello thanks for blog but I am also getting same error as bala,also i would like to ask that if server name/Ip and port change then we need to recompile our flex application,how we can avoid it? please give me complete step by step tutorial for it.....
# Posted By alokob | 2/2/10 1:50 AM
My solution to: "Cannot access the web server. The server may not be running, or the web root folder or root URL may be invalid."

I'm using WAMP 2.0 on my machine and I was receiving that "Cannot access the web server" warning like many others. On a whim I went to the WAMP menu in the taskbar and when to: Apache -> Alias directories -> Add an alias. This opens a command-line and I created an alias (in my case I called it 'flex') . You are then prompted to enter the file path to the directory (the directory must already exist) , in my case I created a folder in the root directory of my c drive "c:\FLEXWEB" because I'm lazy and didn't want to type a long file path. success.

Now I tried to create a project ion flex again and this time when I configured the server:
Web root: C:\FLEXWEB
Root URL: http://localhost/flex
Output folder: C:\FLEXWEB\nameofproject-debug

The web root and URL where now magically valid. I don't know why this worked - I do know that I've messed with the HOST's file and the httpd-vhosts.conf file to set up convenient way's of accessing web-projects I've been working on and I can make wild uneducated assertions that what I did created a clean and uncorrupted virgin space for the magic flex voodoo dance... but really I don't know - I just hope this helps someone whatever the explanation is.
# Posted By Luke | 2/5/10 2:48 AM
I've got the same error
"Cannot access the web server. The server may not be running, or the web root folder or root URL may be invalid"
but only if I'm using a remote server. On localhost, everything works great.
(I'm using Flexbuilder 3 and tomcat 5.5).

I think maybe it's because of the environment variables java_home and java_catalina that aren't visible for the flex-builder (because in localhost everything works great)?

Anyone a clear answer how to manage this problem. I've already lost to much time finding a solution. :-(

# Posted By Flens | 4/2/10 11:14 AM
thanks man! i dont want to install the blazeDS turn-key system too, and you gave me the solution thanks for shared your experience!
# Posted By kosmo | 1/22/11 2:43 PM
I ve followed every instruction your example BlazeDS and flex Java, but while creating flex app, it is displaying that it cannot connect and web server is not running or invalid values of web root and url root. i verified all the steps several times and did not find any mistake in it. i think the problem is with http://localhost:8080/blazeds. how to find out the my systems localhost ? pls. help.
thanks in advance
# Posted By vinu | 2/16/11 2:09 PM
To make it work in Adobe Flex Builder 4- please use this code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:fx="";
            xmlns:mx="library://" layout="absolute" minWidth="955" minHeight="600">
      <!-- Place non-visual elements (e.g., services, value objects) here -->
      import mx.utils.ObjectUtil;
      import mx.controls.Alert;
      import mx.utils.StringUtil;
      private function resultHandler(event:ResultEvent):void
      //used for debugging - shows details about result
      //returned by the Java class method
    ObjectUtil.toString(event.result) );
      private function faultHandler(event:FaultEvent):void
    ObjectUtil.toString(event.fault) );
      <mx:RemoteObject id="ro" destination="helloworld"
   <mx:Panel x="10" y="10" width="440" height="200" layout="vertical" title="Test Flex 3 Using Java" borderColor="#008040" fontFamily="Arial" fontWeight="bold" fontSize="13">
      <mx:Text text="Click The Button To Test Getting Data Into Flex From A Java Class" fontWeight="bold" width="250"/>
      <mx:Spacer height="20"/>
      <mx:Button label="Get Hello World!" click="ro.getHelloWorld()"/>


Note : I have removed the package example from the java class. Now it's just HelloWorld.
It's working in Tomcat 7 and Adobe Flex Builder 4
# Posted By Ashu | 3/8/11 10:42 PM

Thank you so much for this wonderful tutorial. I'm amazed that you posted this article almost three years ago and it still the best simple example for BlazeDS out there.


P.S. Please update for Flex 4. Ashu's example is good except for line 2 has an extra ";".
# Posted By qbnRonin | 3/31/11 12:16 PM
Excellent Philips, thanks a lot i was searching cracking what could be a problem now i could able to run through adobe examples....

# Posted By swaroop | 5/19/11 10:55 AM
hi! i tried to follow your instructions.. the steps are very clear.. (thanks for that ^^).. but then.. when i clicked the get Hello World! button.. i got this error message..

errorID = 0
faultCode = "InvokeFailed"
faultDetail = "Couldn't establish a connection to 'helloworld'"
faultString = "[MessagingError message='Destination 'helloworld' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']"
message = "faultCode:InvokeFailed faultString:'[MessagingError message='Destination 'helloworld' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']' faultDetail:'Couldn't establish a connection to 'helloworld''"
name = "Error"
rootCause = (null)

Hi Bruce I have tried your steps but I get the this error. could you explain What I could be missing. Its really disppointing
# Posted By applvsing | 5/23/11 11:27 AM
Hi Bruce
I did a lot of rechecking on my project and I came to know that the fault is coming because of the unchecking the option of 'use remote object access service' just below the option to select the Application server type (J2EE). I had unchecked it under the impression that this radio option has to be selected only for Live cycle data services. This can be usual reaction of any developer who has not done it before. My request is to alway keep this option selected but in the next screen one can uncheck the first option in the Server technology which asks for the checking the selection of use default location for local live cycle Data Services server. May be because of so many configuration to be done here and some configuration there this point may miss the attention. Moreover, I could explore the possibilities of configuring these setting after we have created the project but unforunately couldn't see any breakthrough. I will definitely post if I will find any way. In the mean time if any one comes across any way to configure these setting later on then, that will be an ice breaker.
# Posted By applvsing | 5/23/11 10:21 PM
I get error message when I run it as air application, did any one has solution for this
# Posted By Nancy | 7/27/11 5:28 AM
Hi Bruce,
Your blog really helped me get started with flex + java (using blazeds).I was able to call java functions from my flex app.
Is it possible that we connect to a java application through this blaze ds integration and at the same time the java app is also able to recieve data through its own socket server from different devices.
# Posted By ashar azeem | 12/22/11 6:44 AM
it worked on web but it didn't work with AIR. is there a way on how to let it work on AIR?
# Posted By anning | 1/9/12 1:45 AM
Struggled for about two weeks to learn creating a small application to transfer data to and fro in Flex-Java, but all the books or documents were so confusing and unclear and thank god I hit your page. It was so clear and accurate and described what everyone else failed to describe.

I followed the instructions and after a struggle of two weeks, succeeded in creating an application to transfer data between Flex and Java.

Thanks bro.
# Posted By George | 3/11/12 1:09 PM
Great post, Bruce. Simple and easy to follow. Got it to work for both Air and Web.
Also, for AIR applications, I found this link to make this example work -
# Posted By Rahul | 6/1/12 4:46 AM
BlogCFC was created by Raymond Camden. This blog is running version Contact Blog Owner