In December 2007 Adobe released part of their Live Cycle (LC) suite as Open Source on Adobe Labs and named it Blaze DS. Having used LCDS for some time I was interested in seeing how the Open Source version was compared to the expensive LCDS suite. The result of this investigation is this write up on how to get started with BlazeDS.
Demo application
In addition to this written stuff I have created a pretty simple demo application which can help you getting started with Blaze DS. It is just a simple app for collecting notes and links, nothing very fancy or interesting but this is just a simple application for showing how easy it is to get started with BlazeDS. The sample application contains a Flex 3 Web- and Air Application and a Java Web Application.
It’s really simple to get this sample running all you need is to extract the files and execute two simple commands. Make sure you have installed the following on your computer:
- Maven
- Java 1.6.x or later
- Flash Player 9
Once you have those two things in place you can follow these simple steps to view the application:
- Download the demo application source code:Â blaze-poc-v3
- Extract the ZIP file to any directory
- Open the file deploy/blazeds-poc.properties and edit the property echo.db.path to reflect the location where you extracted the source code.
- Run the command: install-flex-libs
This command installs the BlazeDS JAR’s in your local repository. - Run the command: mvn install
- Navigate to the directory blaze-poc-web and run the command: mvn jetty:run
- Open the URL: http://localhost:8081/blaze-poc-web/
Now that you have seen the sample application you are probably interested in seeing how BlazeDS is setup. Continue reading and I will go through some of the basic steps. In order to build Flex applications easily you should use Flex Builder 3 as it give you numerous benefits and helps you develop much more rapidly than any other Flex authoring tool.
Configuring BlazeDS in you Java Web Application
Create a Java web application in Eclipse (you might want to use MyEclipse or something similar to make web development even easier in Eclipse). Grab the latest distribution from Adobe Labs and unzip the content to a folder somewhere on your machine. Unzip the file blazeds.war into the root directory of your web application. You should have a folder structure like this:
WEB-INF\flex
WEB-INF\lib
meta-inf
Delete all the JAR-files in the WEB-INF/lib directory, we’re going to let Maven handle the dependencies for us instead of having to do this ourselves. Adobe seems to be stuck in the previous century when it comes to Java development and have not published BlazeDS artifacts to any Maven repository. Luckily the guys and girls developing the Open Source Igenko CMS has put up BlazeDS artifacts in a repository which we can use. BlazeDS dependencies are configured as described in the write up from Igenko.
Upate: There is still no sign of the Blaze DS JAR’s getting put into a public Maven repository and they are now a part of the demo application (thanks Per-Otto!), see a more detailed description of why at the end of this post.
Spring and BlazeDS
In order to enable BlazeDS to utilize the power of Spring you can do this by creating a SpringFactory class. Christophe Coenrates describes the required steps in the article “Using Flex and Spring” on Adobe Developer Center. In the enclosed sample project a SpringFactory class is configured in the configuration file WEB-INF/flex/services-config.xml
<factories>
<factory id="spring"
class="com.moneytalks.blaze.poc.SpringFactory"/>
</factories>
Using Remote Object in Flex
Adobe usually says that you should add the -services compiler argument telling the MXML compiler where the Flex configuration is located. This is IMHO not a very smart way of doing this at it forces you to have the exact same file path in all environments you deploy you application.
Instead of passing in the path for the Flex configuration a better option is to pass information required by RPC- and Messaging Services either with Flash Vars which makes it easy to adjust endpoint servernames, file paths, etc in different environments. This approach was first brought to my attention by Mike Nimer in his blog post Bye bye -services. I recommend following this approach as it makes it easy to deploy your application anywhere without having to recompile your application
Start developing!
That is pretty much all the important thins you need to know before you can start enjoying rapid development using BlazeDS. You will hopefully experience the joy of being able to focus on developing a great application instead of spending time writing boiler plate code moving data between client and server.
In order to get a better overview of the messaging features you can check out some of the great samples provided by Christophe Coenraets.
This article is also available in Norwegian.
Note!
Since I wrote this article it seems as if the artifacts on the Maven repository I used for the demo applciation have become unuseable. Attached to the article is an updated archive which have the BlazeDS JAR-files enclosed (in the directory called /flex-libs) and with a script (install-flex-libs.sh/.cmd) which installs them in your local repository.
Thanks to Per-Otto for updating the demo project and sending me the update!
Note 2!
There is a bug in the POM of the web application, substitute the webApp configuration with the following lines (I will update the sample projcet, but this is a temporary solution):
<webAppSourceDirectory>${basedir}/target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<webXml>${basedir}/target/${project.artifactId}-${project.version}/WEB-INF/web.xml</webXml>
<classesDirectory>${basedir}/target/classes</classesDirectory>
There was an typing error in Note 2 which I have corrected, sorry about that..
The sample should work just fine if you add this to your POM
Comment by leftieFriele — November 14, 2008 @ 10:01 am