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.
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:
Once you have those two things in place you can follow these simple steps to view the application:
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.
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.
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>
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
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>
Subscribe to comments feed (this is global, not just for this entry)
Being accustomed to the development tools for Java development it has been really frustrating to move into the world of Flex and Action Script with it’s immature IDE’s. However it seems as if this is finally getting attention at Adobe and the Open Source project FlexPMD is really becoming a great tool for assuring quality [...]
I have for some time been running Ubuntu on my work-at-home-computer. Having to work with Flex on Linux is a constant struggel and I can understand why most people would just give up. I can see that the number of Flex developers on Linux is quite small, however I think it’s a shame that we’re [...]
One of the most challenging tasks when being architect on a large project is to keep some kind of track on what developers are doing while you are wasting away time in planning meetings and all other kinds of useless management activities. In the Flex echo system there are very few tools which help you [...]
Thanks a lot! We are using Blaze DS without Flex (just Flash and AS3) so I had to downgrade your sample app a little. But still, it was a very good starting point to get into Blaze DS using Spring and Maven.
March 4th, 2008 at 4:45 amUsing Flex sdk_3.0.0.477
May 16th, 2008 at 6:14 pmmvn install fails with
Error: Definition com.moneytalks.blazepoc.utils:MessagingHelper could not be found
@mm just remove the import statement in the echo.mxml file. I forgot to remove it, sorry. I have updated the ZIP with this change.
I also detected an error in the Israfil maven plugin for building the Flex application. It has a dependency for the maven-dependency-plugin version 2.0-alpha4 which no longer exists. To fix it change it to 2.0 in the file net/israfil/mojo/maven-flex2-plugin/1.3/maven-flex2-plugin-1.3.pom in you local Maven repository.
May 18th, 2008 at 5:29 pmI just noticed that the Maven repository I used for the BlazeDS artifacts has an invalid version of the Messaging components… unfortunately Adobe does not like Maven (or care about the fact that the entire globe use it) so they refuse to make them available…
however you can vote for the bug here: http://bugs.adobe.com/jira/browse/BLZ-71
and you’ll also find some links to people who have put the artifacts out on the Maven repositories.
June 12th, 2008 at 2:23 pm[...] er også tilgjengelig på engelsk og i tillegg publisert hos [...]
June 24th, 2008 at 8:28 amhow did you determine the version of the flex JAR’s?
July 25th, 2008 at 6:56 pmThis was just a number I chose for the Flex JARs since there is no offical Maven repository with the Flex JARs. But, rumors has it that we might expect something from Adobe when it comes to Maven support.
July 28th, 2008 at 8:07 ami am gonna show this to my friend, bro
October 6th, 2008 at 3:43 am[...] Dalløkken :: Just Blaze… getting started with Blaze DS :: Covers using Maven with a BlazeDS project, includes a sample [...]
October 14th, 2008 at 7:27 am[...] Dalløkken :: Just Blaze… getting started with Blaze DS :: Covers using Maven with a BlazeDS project, includes a sample [...]
October 14th, 2008 at 10:20 amFor Step3 I took the file blace-poc-web/deploy/blazeds-poc.properties
Somewhere between step 2 and 5 everybody who gets the error “[ERROR] BUILD ERROR
.)
[INFO] ————————————————————————
[INFO] c:\dev\applications\Adobe\Flex Builder 3\sdks\3.0.0 does not exist. flex.home property must be set.”
needs to change somthing more:
PATH_TO_YOUR_FLEX_SDK_VERSION
in “UNZIPDIR/blaze-poc-flex/profiles.xml”.
Setting PATH_TO_YOUR_FLEX_SDK_VERSION to ${env.FLEX_HOME} and setting this variable in my environment variables in the user variables to the right path did let me finish step 5 (don’t forget to restart the “cmd” if ur os has “Win” in its name, for the new set/created variables to be accessable). So finally after about total 45′ from step 1 to step 6 finally it told me Jetty was started. (Maybe its just me, maybe its because this is the first time I use maven an it downloaded a LOT of things
But this is bad: by clicking on the link in step 7 I get a “jetty-powered”
‘ERROR 503
SERVICE_UNAVAILABLE
RequestURI=/blaze-poc-web/’
maybe caused by those to Warning while executing step 6 (outcome in this order):
2008-11-13 21:12:38.877:/blaze-poc-web:INFO: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
2008-11-13 21:12:38.095::WARN: Failed startup of context org.mortbay.jetty.plugin.Jetty6PluginWebAppContext@1e22632{/blaze-poc-web,D:\tmp\_developtes
t\blaze-poc-v3\blaze-poc-web\src\main\webapp}
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/classes/applic
ationcontext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/classes/applicationcontext.xml]
[...a lot of stack...]
2008-11-13 21:12:38.095::WARN: Nested in org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from Servle
tContext resource [/WEB-INF/classes/applicationcontext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource
[/WEB-INF/classes/applicationcontext.xml]:
java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/classes/applicationcontext.xml]
[...a lot of stack again...]
2008-11-13 21:12:38.283::INFO: Started SelectChannelConnector@0.0.0.0:8081
[INFO] Started Jetty Server.
Has anybody any idea what went wrong? (I tryed both replacing and inserting the code from “Note2!” in the named file. replacing told methis at step 6:
‘[ERROR] BUILD ERROR
[INFO] ————————————————————————
[INFO] Webapp source directory D:\tmp\_developtest\blaze-poc-v3\blaze-poc-web\target\blaze-poc-web-${project.version does not exist’
)
Sorry for this big comment, I couldn’t find a mailcontoct at this site.
Greetings from Germany,
November 13th, 2008 at 10:36 pmKarfau
There was an typing error in Note 2 which I have corrected, sorry about that..
November 14th, 2008 at 10:01 amThe sample should work just fine if you add this to your POM
Just to note that these mavenized libraries are by now available at:
http://repo1.maven.org/maven2/com/adobe/blazeds/
Thought it could help some people since this blog is still easily reached when googlizing “blazeds maven”
January 11th, 2010 at 12:45 pm