Working with Eclipse is a great experience with lots of powerful features at your fingertips.  Unfortunately, for a beginner it can be a little difficult to get used to and not immediately obvious how to do certain tasks. Setting up projects can be particularly challenging, especially if you have a lot of extra development requirements (for example, using Maven, Ant, Sping, etc.).  Using the standard Adobe getting started guide gives you a gentle introduction to remotiing and messaging, but doesn’t give you details on how to set up a clean “bare bones” application.

This article lists the steps to create a bare bones BlazeDS server configuration using the turnkey solution.

What You’ll Need

First I’ll assume you have already downloaded and installed the following:

  • Eclipse
  • Flex Builder (or Flex Builder plugin for Eclipse)
  • BlazeDS turnkey

If you followed all of the instructions for installing and running the basic BlazeDS turnkey, then you currently have a tomcat server running a demo on localhost (port 8400). If successful, you should see the BlazeDS index page by clicking here. If you see an error at this point, then you can go and check your server logs and try to correct it. Do not proceed with this guide until you see the functioning index page.

Now you have successfully installed Tomcat and BlazeDS turnkey, you will need to turn it off as you won’t be using it from here. Yes that’s right, turn it off! Shutdown the tomcat server using any method you choose (i.e. ctrl-c, shutdown.bat, stop the service, catalina stop, etc.). This will free up port 8400 and allow you to run the server from Eclipse after we have configured it.

Setting up Tomcat in Eclipse

These are the steps for creating a connection to the tomcat server:

  1. Start Eclipse and select the “Java EE” perspective
  2. In the bottom panel, select the “Servers” tab
  3. Right click on the panel and select “New->Server”
  4. Select the server settings and point them to your newly installed tomcat server. The installation directory should be “<base turnkey installation dir>\tomcat” (in my case this is “C:\blazeds\tomcat”).
  5. Click Finish

Once you have completed these steps, you should see a new server created in the “Servers” panel, plus a new tree entry in the Project Explorer (also called “Servers”). Your environment should look a bit like this.

Creating a Project

The next step is to create the server side project.

  1. Create a new “Dynamic Web Project” with the following settings:
    • Project name: myBlazeProject
    • Target Runtime: “Apache Tomcat x.x” (this is the server you created in the last section)
    • Configuration: Default Configuration for Apache Tomcat x.x
  2. Click “Finish”

After creating the project, your environment should look a little like this.

Creating the Bare Bones BlazeDS Configuration

Ok, we now have the server set up and a basic project. The next steps set up the BlazeDS libraries and configure the environment to auto-update the server when the project is built.

  1. Overwrite the contents of your “WebContent” directory with the BlazeDS directory structure “<base turnkey installation dir>\tomcat\webapps\blazeds”.  The result should look a little like this.
  2. Right click on your newly created “myBlazeProject” project and select “Properties”
  3. Select “Java Build Path” from the list in the left hand panel.
  4. Set the “Default output folder” to “myBlazeProject/WebContent/WEB-INF/classes”. This will cause your web server to automatically update every time you rebuild your project.

Create a Basic Remote Class

Great! We’re nearly there… now let’s create and configure a Java class so we can test our configuration.

  1. In the “myBlazeProject/WebContent/WEB-INF/src” directory, create a new class called HelloWorld.java.
  2. public class HelloWorld {
        public String sayHello(String name) {
            return "Hello, " + name;
        }
    }
  3. Configure BlazeDS to allow remoting requests to the HelloWorld class by adding a destination to the “remoting-config.xml” file found in the “myBlazeProject/WebContent/WEB-INF/flex” directory. Use the following destination configuration:
  4. <destination id="HelloWorld">
        <properties>
            <source>HelloWorld</source>
        </properties>
    </destination>
  5. Start your application server by clicking on the green “play” button. Verify your web application is configured by going to the following URL (The url and port may vary depending on your application server configuration and what you named your project): http://localhost:8400/myBlazeProject/
    If your server is not configured to display directory contents, you might see a 404 error. This is OK, but failure to connect errors are not.

Create a Flex Project

Whether you use the Flex Builder 3 plugin for Eclipse or standalone Flex builder 3 installation is entirely up to you. It’s possible to manage your Flex and Java code in one IDE if you use the plugin, but you may prefer the standalone IDE instead.

These steps create the Flex project and link it to your server:

  1. Create a new Flex Project
    • Project name: testHelloWorld
    • Application server type: J2EE
    • Use remote object access service: enabled (with “LiveCycle Data Services” selected)
  2. Click “Next >”
  3. Use these settings:
    • Root folder: point this to your “WebContent” directory in the Java project
    • Root URL: http://localhost:8400/myBlazeProject/
    • Context Root: /myBlazeProject
  4. Click “Validate Configuration”
  5. Click “Finish”

Create a Client Test Application

Finally, let’s update the Flex project to use our BlazeDS Server so we can test our remote object:

  1. Update the testHelloWorld.mxml file with the following code:
  2. <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    
        <mx:RemoteObject id="ro" destination="HelloWorld"/>
        <mx:TextInput id="n" change="ro.sayHello(n.text)"/>
        <mx:Label text="{ro.sayHello.lastResult}"/>
    
    </mx:Application>
  3. Build and Run!

If all went well, then you should have a working Flex app that connects to your remote service and responds with “Hello, <your name>”.  Something like this.

Troubleshooting

If you for some reason your components don’t talk to each other after following all the steps, try cleaning the projects and restarting the server.

Server Side Debugging

Now that we have created the bare bones server in this manner, we can use the fantastic debug functionality provided by Eclipse in the Java server code as well as the Eclipse client code!

To use the Java debug mode, just add your breakpoints to your source files and make sure the server is running in debug mode. Then when your Flex apps call the remote objects, they will trigger the debug mode and Eclipse will automagically put you into Java debug mode.

Further Reading

This article was inspired by the excellent in depth articles provided by the following sources:



38 Comments to “Setting Up a Basic BlazeDS Server with Debugging”


  1. Winston — March 25, 2009 @ 16:40

    Perfect article! You are great! Thank you very much. You had saved many hours of environment setup ;)

  2. donkeybandit — March 25, 2009 @ 18:04

    You’re very welcome Winston. Thanks for the feedback.

  3. DaddyDog — April 10, 2009 @ 21:49

    Nice article and very helpful. Validate Configuration kept failing for me, until I relalized that I needed to go back and add the myBlazeDSProject to to the Server under add and remove. Also the placement of the src/java didn’t allow me to debug and see the java src. Didn’t get to the bottom of this, so I ended up using WTP. Thank for posting.

  4. donkeybandit — April 12, 2009 @ 19:38

    This can be a pretty temperamental environment to set up. As mentioned in the troubleshooting section, cleaning the project (from the menu “Project->Clean..”) can help to alleviate problems as well as restarting the server/Eclipse and sometimes the server hardware itself. This method really works so it is worth retracing your steps.

    Incidentally, the “validate” button in FlexBuilder can also be inconsistent. I have found that the client and server will still communicate correctly even if the validation failed.

    Once set up, it all works very nicely and I have had few problems with it.

  5. iwanderafar — April 16, 2009 @ 22:06

    Help! I’ve done everything through “Create a Flex Project”, but when I try to validate the new Flex project configuration, it gives me an error “Cannot access the web server. The server may not be running, or the web root folder or root URL may be invalid.”

    When I validated the server was running after setting up the BlazeDs Turnkey, I saw the BlazeDS page. Now when I bring up http://localhost:8400 I get:
    Directory Listing for /
    Apache Tomcat/6.0.14

    My eclipse project is named ReportGenTool and I’ve overwritten the WebContent directory with the META-INF and WEB-INF directories from the BlazeDS installation (C:\blazeds\tomcat\webapps\blazeds). According to Eclipse the server is running.

    My Flex project is named ReportGenTool and is located in another directory away from the Eclipse project directory. My root folder is: C:\Projects\workspace\ReportGenTool\WebContent
    Root URL: is http://localhost:8400/ReportGenTool/
    Context root is: /ReportGenTool/

    Any idea what might be wrong? What didn’t I configure that needs to be configured?

    Thanks in advance.

  6. donkeybandit — April 17, 2009 @ 0:52

    OK, the validate button doesn’t always work when setting up the project, particularly if you are using the Flex plugin to Eclipse instead of separate FlexBuilder and Eclipse. Getting a 404 error is ok too as you’re not creating a web page here, you’re creating an endpoint. As long as you can continue with creating the project carry on and finish the setup.

    Go through and finish creating the Hello World client/server and config. You will likely find that it will work for you.

    As mentioned in the troubleshooting section: if you have problems, make sure you clean your projects and confirm that your current Project is running on the server (see DaddyDogs comment above).

  7. Schalk — April 30, 2009 @ 20:04

    Thank you!
    Every step worked exactly as advertised!
    I have been struggling for a few days now trying to put all the blazeds bits and pieces together using docs and tutorials.

  8. sanjay patni — May 20, 2009 @ 1:28

    I was able to configure and run application in eclipse. Now in order to deploy as a war file in tomcat or any other app server what is involved. Has any one tried deploying war to app server from eclipse. I tried creating war and deployed that to tomcat. UI shows up but does not fetch any data from the server. Any pointers would be of good help for deployment as war in app server.

  9. Milan — June 3, 2009 @ 17:17

    Thanks a lot for this article! I had some problems finding a working setup, since I am quite new to application server issues in Java. Especially the integration with Eclipse enables an efficient workflow…

    This is exactly the kind of tutorial I was vainly searching for on Adobe’s BlazeDS pages. It is very much appreciated!

  10. Tom Richards — August 7, 2009 @ 15:28

    Hi,

    Good tutorial, of only I’d found it earlier.

    I already have my web app going on localhost using blazeds remoting, to provide access to my hsqldb database.

    I now have the challenge of deploying it on an existing tomcat server. However when i combine the blazeds.war with my app, package it up, and deploy it, i cant get access my data.

    Do you know how to get BlazeDS working, not on the tomcat instance that the turnkey dist comes with.

    Regards,
    Tom

  11. Tony — August 9, 2009 @ 8:44

    Nice Post ,thanks ,But I wonder if this is the best way to integrate blazdeds and jee in eclipse ,can I just click run on server ,and eclipse automatically start tomcat and deploy the applicatin ? Because flex builder does has a run as server choice.

  12. donkeybandit — August 9, 2009 @ 19:13

    Tom,

    You should be able to get BlazeDS working by copying the correct files into your structure. Please re-read the section that starts:

    Overwrite the contents of your “WebContent” directory with the BlazeDS directory structure “\tomcat\webapps\blazeds

  13. donkeybandit — August 9, 2009 @ 19:14

    Tony,

    Yes, you can configure ant scripts to perform more complex “Run” operations.

  14. Josh — August 16, 2009 @ 18:33

    I followed this carefully (twice), and bombed out on the Flex part. The server validation failed and then my AIR app threw an exception about “Send failed” and my Flex app also couldn’t find what it was looking for. I cleaned projects etc.

    I’m using FB 4 beta, but the steps are the same (except a BlazeDS option is available in project creation and you need to wrap the RO in ).

    Here are some questions:
    1) I assume that after running the myBlazeProject, I shouldn’t stop it before running the testHelloWorld project. Correct?

    2) I don’t understand how publishing the java into the local project file structure ties it into Tomcat. Shouldn’t we be publishing into the /blazeds/Tomcat directory structure somewhere? Or does Eclipse do some magic to tell Tomcat where to find requests to our project?

    TIA for any help.

  15. alexander — August 29, 2009 @ 19:56

    In the “myBlazeProject/WebContent/WEB-INF/src” directory, create a new class called HelloWorld.java.

    then it doesn’t work for me

    It works when I leave the file in
    “myBlazeProject/Java resourcers: src” folder

  16. dvphongit — September 15, 2009 @ 15:36

    Hi,
    I am using LiveCycle Data Services ES 2.6.1
    I’m very tired with error:
    [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:8400/TestApp/messagebroker/amf'"]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:220]
    at mx.rpc::Responder/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:53]
    at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
    at mx.messaging::ChannelSet/faultPendingSends()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1482]
    at mx.messaging::ChannelSet/channelFaultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:975]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.messaging::Channel/connectFailed()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\Channel.as:997]
    at mx.messaging.channels::PollingChannel/connectFailed()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel.as:354]
    at mx.messaging.channels::AMFChannel/statusHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\AMFChannel.as:390]

    Help me, please!
    Thanks a lot!

  17. Joey — October 16, 2009 @ 22:35

    Just one thing, I’d like to add here.
    You create a remote object with an id and a destination. I must say, I’m quite new in working with flex and blaze. But I am quite sure that the endpoint location is missing on flex side.
    So you should add “endpoint=”http://localhost:8080/yourproject/messagebroker/amf”, to let the client now, where his endpoint is located.
    If I’m misunderstanding something, feel free to correct me. But thats one thing i was missing in most tutorials. After I added that to my definition of the remote object, it all worked fine.

    regards, Joey

    PS: this relates to the error message: “MessagingError message=’Destination ‘helloworld’ either does not exist or the destination
    has no channels defined (and the application does not define any default channels.”

  18. Barry — January 6, 2010 @ 9:54

    Joey. The default endpoint for remote objects is specified in the remoting-config.xml file; a link to this file (via the services-config.xml) should be included in the flex projects compiler arguments if you setup the flex project correctly.

  19. coolf — January 30, 2010 @ 3:14

    i just want to know which is better, work eclipse and flex builder plugin together or separate.

  20. coolf — January 30, 2010 @ 3:17

    anothe thing , i follow the tutorial and in flex builder there is the field Output folder with pointo to C:\wsflex\myBlazeProject\WebContent\testHelloWorld-debug, its ok at first but when i change something in flex builder the changes doesn’t appear, in flex builder there is a bin-debug folder in the project i think this is linked with C:\wsflex\myBlazeProject\WebContent\testHelloWorld-debug, but the changes doesn’t appear, why?

  21. LCDS Application-Specific Data Source | Karin's Pensieve — February 8, 2010 @ 1:26

    [...] Server and Client applications as described here. Setup data source in Tomcat as described here. But, instead of putting myapp.xml under [lcds [...]

  22. Vinicius Camara — February 22, 2010 @ 15:27

    This code did not work to me.
    I dont know why, but the flex project not works in java project.

    You said:
    Root folder: point this to your “WebContent” directory in the Java project
    Is that a physical path?

    Root URL: http://localhost:8400/myBlazeProject/
    Context Root: /myBlazeProject

    I use a standalone flex with eclipse, so, I developed the application using:
    1. Flex Project
    2. I used blazeDs WAR file

    I dont know why but I’m always have a problem with a deploy.
    So, now works with this option but I will try use your configuration again.

    Congratulations.
    Best regards.

  23. Swan — February 24, 2010 @ 16:00

    Thanks for this great tutorial !

    Helped me a lot getting ready to develop server-side code. Eclipse amazes me more and more every day :p

    Keep up the good work, cheers !

  24. Flex/Air: Setting Up a Basic BlazeDS Server with Debugging « FLASH CMS (Flash Content Management System) — March 9, 2010 @ 14:16

    [...] http://flexbandit.com/archives/55 [...]

  25. Flens — April 2, 2010 @ 17:22

    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 try to connect to a remote server (local host works fine).
    (flexbuilder 3 and tomcat 5)

    I think maybe it’s because of the vars java_home and home_catalina that aren’t visible from the flexbuilder?

    Anyone an idea how to fix this?

    Regards,
    Joachim

  26. Kun — May 26, 2010 @ 9:49

    Thanks for the tutorial..

    First, the validate button didn’t worked for me, too. But I ignored it and run the flex project and i got an error message. Later, i copied the blazeds.war to my java project folder and it worked.

  27. kali — July 9, 2010 @ 9:42

    Hi All,
    This is a best documentation available for beginner for setting up the blazsds,eclipse and flex.

    Greate job …….
    Keep it up

  28. Ned — July 28, 2010 @ 13:01

    Not only have you saved me days of project configuration but I also learned a few new things. Thank you so much. Why can’t those idiot at Adobe simplify this process. I am using Flash builder 4 and it has a bug with the project set thank to you I am now move on learning the flex framework.

  29. Ron — September 7, 2010 @ 20:46

    Hello,

    amazing tutorial!!! It helped so much :)
    Everything works except one error and I have spent significant time trying to identify the source. My instincts tell me that it is not finding a .class file. Maybe somebody who is wise and has more experience can help ;)

    thanks!!!!
    Ron

    [RPC Fault faultString="Cannot create class of type 'HelloWorld'." faultCode="Server.ResourceUnavailable" faultDetail="Type 'HelloWorld' not found."]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:345]
    at mx.rpc::Responder/fault()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
    at mx.rpc::AsyncRequest/fault()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:113]
    at NetConnectionMessageResponder/statusHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:604]
    at mx.messaging::MessageResponder/status()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:264]

  30. Manivannan — December 10, 2010 @ 13:23

    Hi,

    Thanks man, this is really helpful..

  31. kirrilyw — January 14, 2011 @ 9:57

    I keep getting this in my server console whenever I try to access http://localhost:8005/BlazeDSTester. Driving me mad, any ideas?

    (note my server.xml has port 8005 in it, and my project is called BlazeDSTester)

    Thanks from me too for posting this tutorial. I’m sure it will be super helpful once I get over this hiccup….

    Kirrily

    Jan 14, 2011 4:53:39 PM org.apache.catalina.core.StandardServer await
    WARNING: StandardServer.await: Invalid command ‘GET /BlazeDSTester HTTP/1.1′ received
    Jan 14, 2011 4:53:40 PM org.apache.catalina.core.StandardServer await
    WARNING: StandardServer.await: Invalid command ‘GET /favicon.ico HTTP/1.1′ received
    Jan 14, 2011 4:53:43 PM org.apache.catalina.core.StandardServer await
    WARNING: StandardServer.await: Invalid command ‘GET /favicon.ico HTTP/1.1′ received

  32. AratKumar — January 31, 2011 @ 10:12

    Nice article it really helped me but the thing is without java package it is working fine,but when I am creating a package like “com.remoteobjects” and kept POJO java file inside it and making changes in the “remote-config.xml”

    com.remoteobjects.HelloWorld

    file and running the application in tomcat6, it is showing the destination “com.remoteobjects.HelloWorld” does not exist. Can you please help me on this

  33. suresh — May 18, 2011 @ 8:20

    Hi ,

    Thanks, this is really simple to understand the Blazeds .

  34. mohan — August 19, 2011 @ 17:03

    I keep getting this error if I run the swf directly.Please help

    Also I get the 404 error when i run from flex builder

    [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://localhost/myBlazeProject/messagebroker/amf'"]

  35. peter — August 23, 2011 @ 19:26

    this is embarrassing to ask, but how do i change the WebContent folder to point to another location? i’ve used Eclipse extensively, and for some reason i can’t figure it out….
    help!

  36. peter — August 23, 2011 @ 19:30

    nevermind! dude, that is REALLY embarrassing! i try not to read ahead because i tend to miss steps, but there were the steps right there following it…..

  37. newbie — January 7, 2012 @ 18:28

    No, followed the steps exactly, but no result. Are these old instructions?

  38. ERD — March 1, 2012 @ 16:59

    One comment – in order to make this work and not get a 404 error when running the Flex app, I needed to Add the java project to the Server. Meaning, I right-clicked on the Server, and chose “Add and Remove…”. Then, I selected the “myBlazeProject” and Added it (moved it to the right-side).

    After that, in the Servers tab, you will see your server with a status of “Started, Synchronized”).

    Also, you can then expand the server and see that the Java project is Synchronized with that server.

    HTH from a fellow newbie.



Write a comment


Name




    
FlexBandit is based on WordPress platform, RSS tech , RSS comments design by Gx3.