Using BlazeDS Version 4 To Integrate A Flex Application With A Java Backend Built With Flash Builder

Introduction

Adobe and SpringSource are working together to make it easier for Java developers to use Java and Spring on the backend and Flex-Adobe's rich internet application framework [refer 2]--on the frontend.  Adobe has an open source project called BlazeDS [refer 8] that provides the plumbing to enable a Flex application to communicate data with a Java application running on a server.  The new version of the Flex IDE--Flash Builder 4 [refer 3]--provides extensive data wizards that can auto detect the services a Java application is exposing to a remote application such as the Flex client.  SpringSource has created a Spring Flex module [refers 1 and 6] that enables Java developers to use Spring to set up the BlazeDS plumbing on the server side and to use XML or annotations to mark which classes and methods should be available to be called by the Flex application.

James Ward, an Adobe Flex evangelist, has an excellent video tutorial [refer 5] on how to wire up a Java application on the backend to provide data to a Flex application on the front end.  The problem with his tutorial is that he skims over some important details and his example doesn't use Maven.  I spent several very frustrating hours trying to figure out how to create a version of his example that uses Maven with the Java application that provides the backend data and the Spring-BlazeDS plumbing while still being able to use the Flash Builder data wizards James shows in his video.

The web is full of Flex - Java examples.  Unfortunately, most of those don't take advantage of the latest versions of the Spring Flex module (1.5) and BlazeDS (4) that are necessary so that the Flash Builder 4 data wizards [refer 9] can auto detect the services exposed by the Java application.  Also almost all of the examples are overly complex and try to show off everything you can do with Flex and BlazeDS.  Many of the examples that do use Maven, use the Flex-mojos plugin [refer 11] to compile the Flex application's source code and do not use the Flash Builder IDE.  An even tougher problem is that some of the artifacts needed to build a Flex - Java application using the latest versions that support Flash Builder 4's data wizards are not available in a public Maven repository. 

The goal of this article is to demonstrate how to create a Maven version of the example application James Ward shows in his video.  The example application that accompanies this article uses the latest versions of the Spring Flex module and BlazeDS on the Java side so that Flash Builder can auto detect the exposed services.  I'm just learning how to use Flex, BlazeDS, Spring, and Java together so please comment if I've gotten something wrong. Consult the references below for much more information.

Prerequisites

  1.  Watch the video created by James Ward [refer 5] (it's only 11 minutes long) to get an idea of how to integrate Flex and Java and the capabilities of the auto detect data wizards in Flash Builder 4.
  2. Get a copy of Flash Builder 4 (there is a 60 day trial and a free license for students/educators).  There is a Eclipse plugin and a full standalone version built on top of Eclipse 3.5.  If you get the full standalone version of Flash Builder 4 you'll need to do a software update in Flash Builder to get the Java EE tools needed to build a Java web application [refer 12]. You'll also need to add the Maven plugin.
  3. Get a Java Servlet container such as Tomcat 6.

Example Applications

There are two example applications [refers 15 and 16].  One is a Java application designed to run on a web server such as Tomcat.  This application uses Maven to pull in all the dependent artifacts.  Note there are 5 BlazeDS 4 artifacts that are not in a public Maven repository and will need to be installed manually into your local repository (more on that later).  The Java application uses the Spring Flex module and BlazeDS 4 to expose a simple HelloService's getHello method that returns a hello message (which is injected by the Spring framework). 

This service can be auto detected by the Flash Builder 4 data wizards in the second application, which is a Flex client.   The Flex client application shows the user a button that when clicked makes a call to the getHello method and then displays the returned String in a label.

After downloading both applications (which are zipped project archives), you should be able to import them using the File - Import feature in Flash Builder 4 (aka Eclipse 3.5). 

Java Application

In Flash Builder switch to the Java EE perspective and examine the pom.xml under the flex_simple_server_example project folder.  This pom contains the standard dependencies for a Java Spring application.  What's new are these dependencies.

<dependency> <groupId>org.springframework.flex</groupId>
<artifactId>spring-flex-core</artifactId> <version>1.5.0.M1</version> <type>jar</type>
<scope>compile</scope> </dependency> <dependency> <groupId>com.adobe.blazeds</groupId>
<artifactId>blazeds-core</artifactId> <version>${blazeds.version}</version>
</dependency> <dependency> <groupId>com.adobe.blazeds</groupId> <artifactId>blazeds-common</artifactId>
<version>${blazeds.version}</version> </dependency> <dependency> <groupId>com.adobe.blazeds</groupId>
<artifactId>blazeds-proxy</artifactId> <version>${blazeds.version}</version>
</dependency> <dependency> <groupId>com.adobe.blazeds</groupId> <artifactId>blazeds-remoting</artifactId>
<version>${blazeds.version}</version> </dependency> <dependency> <groupId>com.adobe.blazeds</groupId>
<artifactId>blazeds-rds-server</artifactId> <version>${blazeds.version}</version>
</dependency>

The first dependency is for the Spring Flex module.  The version is for the 1.5.0.M1, a milestone release, which is not in the Maven central repository.  So if you examine the repositories section of the pom you'll see the repository setting where this milestone release is available.  The Spring Flex core artifact has several transitive dependency, including for version 4 of the BlazeDS artifacts.  The version 4 BlazeDS artifacts are not available in a public Maven repository.  Follow these instructions to get them and install them into your local Maven repository.

Get The BlazeDS Version 4 Artifacts

  1. Go to this web site and download the latest binary version of BlazeDS:  http://opensource.adobe.com/wiki/display/blazeds/download+blazeds+trunk
  2. Unzip the downloaded file
  3. In the folder created by unzipping the file will be a blazeds.war file - unzip it.
  4. Open a terminal window and navigate to the blazeds/WEB-INF/lib folder
  5. In the lib folder are these jars:
    1. flex-messaging-common.jar
    2. flex-messaging-core.jar
    3. flex-messaging-proxy.jar
    4. flex-messaging-remoting.jar
    5. flex-rds-server.jar
  6. Use the Maven install command to install these artifacts to your local repository (note use the version number of the build you downloaded and be sure to update the version number in the pom.xml)
    1.  mvn install:install-file -Dpackaging=jar -DgroupId=com.adobe.blazeds -Dversion=4.0.0.14593 -DartifactId=blazeds-common -Dfile=flex-messaging-common.jar
    2. mvn install:install-file -Dpackaging=jar -DgroupId=com.adobe.blazeds -Dversion=4.0.0.14593 -DartifactId=blazeds-core -Dfile=flex-messaging-core.jar
    3. mvn install:install-file -Dpackaging=jar -DgroupId=com.adobe.blazeds -Dversion=4.0.0.14593 -DartifactId=blazeds-proxy -Dfile=flex-messaging-proxy.jar
    4. mvn install:install-file -Dpackaging=jar -DgroupId=com.adobe.blazeds -Dversion=4.0.0.14593 -DartifactId=blazeds-remoting -Dfile=flex-messaging-remoting.jar
    5. mvn install:install-file -Dpackaging=jar -DgroupId=com.adobe.blazeds -Dversion=4.0.0.14593 -DartifactId=blazeds-rds-server -Dfile=flex-rds-server.jar
    6.  (the above is from a thread entry by "pledge" found here: http://forum.springsource.org/showthread.php?t=77454)

Exposing A Java Class As A Service Flex Can Use

In the Java application open the class HelloServiceImp.  This class uses Spring provided annotations that enable it to be called from the Flex application. 

@Service("helloService") @RemotingDestination(channels =
{"my-amf"}) public class HelloServiceImpl implements HelloService {

private Log logger = LogFactory.getLog(this.getClass()); private String
helloMessage; @RemotingInclude public String getHello() {

logger.debug("In method getHello of class HelloServiceImpl"); return
getHelloMessage() ; }

The annotation @Service("helloService") marks this class so that Spring can auto detect it by scanning the class path.  The value in parenthesis is the name of the service that will be exposed to the Flex application.  The annotation @RemotingDestination  tells Spring that this class should be exposed to the Flex application and the channel element states that name of the channel is my-amf (see the Spring BlazeDS reference guide and the BlazeDS documentation for more information about channels).  The annotation @RemotingInclude is used to mark which methods of the class Flex may use.

Setting Up Spring To Work With BlazeDS

There is some additional configuration you must do to setup Spring to work with BlazeDS.  Open the web.xml file.

<servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param> <param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value> </init-param> <load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping> <servlet-name>spring</servlet-name>
<url-pattern>/messagebroker/*</url-pattern> </servlet-mapping> <!-- set up the Remote Data Source servlet so that Flash Builder
IDE can auto detect remote data sources exposed by this application -->

<servlet> <servlet-name>RDSDispatchServlet</servlet-name> <servlet-class>flex.rds.server.servlet.FrontEndServlet</servlet-class>
<init-param> <param-name>messageBrokerId</param-name> <param-value>_messageBroker</param-value>
</init-param> <init-param> <param-name>useAppserverSecurity</param-name>
<param-value>false</param-value> </init-param> <load-on-startup>10</load-on-startup>
</servlet> <servlet-mapping id="RDS_DISPATCH_MAPPING"> <servlet-name>RDSDispatchServlet</servlet-name>
<url-pattern>/CFIDE/main/ide.cfm</url-pattern> </servlet-mapping>

You need to set up the Spring DispatcherServlet and map it to handle any requests made to the messagebroker path.  By default this is where the Flex application will send its requests for the services exposed by the Java application.

Note the RDSDispatchServlet setup in web.xml.  This Servlet enables the Flash Builder data wizard to auto detect the Java services exposed by the Spring Flex module.  This Servlet's class is provided by the BlazeDS version 4 jars.

In folder WEB-INF/flex is a services-config.xml file.  This file defines the channel BlazeDS should use for communicating with the Flex application.  If your Flex application will connect to the Java backend over the standard AMF channel you should not have to change this file. If you need to enable security or other features consult the BlazeDS and Spring Flex documentation for what to put in this file.

In the Spring configuration file--applicationContext.xml in my example--is this code that configures Spring to expose the classes annotated with @Service and @RemotingDestination. Note that you'll need to include the flex namespace in the Spring configuration file (see applicationContext.xml in the Java application download).

<flex:message-broker>
    <flex:remoting-service default-channels="my-amf" />
</flex:message-broker> <context:annotation-config /> <context:component-scan
    base-package="name.brucephillips.flex_simple_server_example.service" />


Build and Deploy The Java Application

Use the Maven package command to build the Java application into a war file.  Copy the war file to your Servlet container's webapps folder and startup your Servlet container.  I used Tomcat 6 for this example.  In the console output you should see these messages.

INFO: Initializing Spring FrameworkServlet 'spring'
[BlazeDS]No login command was found for 'Apache Tomcat/6.0.20'. Please
ensure that the login-command tag has the correct server attribute
value, or use 'all' to use the login command regardless of the server.
[BlazeDS]Endpoint 'my-amf' created with security: None at URL:
http://{server.name}:{server.port}/{context.root}/messagebroker/amf

These messages indicate that Spring has successfully setup BlazeDS to enable Flex to communicate with the services exposed by the Java application.   Leave the server running as we next explore the Flex client application.

Flex Client Application

In Flash Builder 4 switch the perspective to Flash and open the flex_simple_client_example project.  The path to my webapps folder is /apps/tomcat/webapps.  If your not using Tomcat or the path to your webapps folder is different than mine you'll need to modify the flex_simple_client_example project's properties so that the project can find your Servlet container webapps folder.

Right click on the flex_simple_client_example folder and select properties.  Click on the Flex Compiler choice in the left hand window.  In the Additional Compiler Arguments field modify the path to the services-config.xml file to fit your settings (remember this file is in the WEB-INF/flex folder of your deployed Java application).  Click the apply button. 

Click on the Flex Server choice in the left hand window.  In the Root folder field modify the path to your webapps folder.  In the Root URL change the port number if your Servlet container is not running on port 8080.  In the Compiled Flex application location change the path of the output folder to be to the path to your webapps folder.  Click OK.

You can now use the technique explained in James Ward's video to have the Flex application auto detect the services provided by the Java application. Click on the Data/Services tab. If you see a HelloService data source right click it and select delete. Select all in the pop up window to delete all the files Flash Builder created previously (because you've changed the path to the webapps folder, you need to recreate this data source).

You should now have a link Connect to Data/Service... in the Data/Services window.

Click on the Connect to Data/Service... link. Select BlazeDS as the service type and then click next. Click on the check box for no password required and click the OK button. You should now have this window that shows Flash Builder has auto detected the helloService provided by the Java application (flex_simple_server_example).

Check the box next to helloService and click the Finish button. You should now have the HelloService data source in the Data/Services window.

When finished connecting to the service you should have a HelloService with a getHello method that returns a String in the Data/Services window in Flash Builder.  You can right-click on this method and select Test Operaton.  Click on the Test button in the Test Operation window and you should get a response value of "Hello Flex User!"  This test confirms that the Flex application can successfully communicate with the Java application.

In the src folder of project flex_simple_client_example is the flex_simple_client_example.mxml file that containes the source code for the Flex client application.  This application follows the technique demonstrated by James in his video.  It uses the HelloService ActionScript class (see the src/services folder) that was created by Flash Builder when you went through the process of auto detecting the services exposed by the Java application. 

<fx:Declarations>

    <s:CallResponder id="getHelloResult" />

    <services:HelloService id="helloService">
        <services:channelSet>
            <s:ChannelSet>
                <s:AMFChannel
                    uri="http://localhost:8080/flex_simple_server_example/messagebroker/amf" />

            </s:ChannelSet>
        </services:channelSet>


    </services:HelloService>

</fx:Declarations>

Note that if your Servlet container where you deployed the flex_siimple_server_example application is not running on port 8080 you'll need to change the port value to match your setup.

Build and Run The Flex Client Application

Right click on the flex_simple_client_example and select Build Project (I have Build Automatically  turned off in Flash Builder, if you have build automatically turned on you can skip this step).  Flash Builder will build the project and deploy the build files to the flex_simple_server_example folder in your webapps folder. 

Right click on the flex_simple_client_example and select Run As - Web Application.  Your default browser should open a window and browse to http://localhost:8080/flex_simple_server_example/flex_simple_client_example-debug/flex_simple_client_example.html.  You should see a button with the text Get Hello. Click on the button and you should see a label appear with the text Hello Flex User!

Summary

I had previously written about how to use BlazeDS to integrate Flex and Java. With Adobe's Flash Builder 4 and Spring's Flex module it is now easier to use BlazeDS and Java on the backend of a Flex application. There is much more you can do with Flex--BlazeDS--Java so explore the references below. If I got anything wrong in this article or you have a problem using the example applications please post a comment.

References

  1. Spring BlazeDS Integration Reference Guide, http://static.springsource.org/spring-flex/docs/1.5.x/reference/html/index.html
  2. Flex Overview, http://www.adobe.com/products/flex/overview/
  3. Adobe Flash Builder 4, http://www.adobe.com/products/flashbuilder/
  4. Flex and Java, http://www.adobe.com/devnet/flex/flex_java.html
  5. Flash Builder 4 Data Wizards with Java and Spring, James Ward, http://www.adobe.com/devnet/flex/articles/flashbuilder4_datawizards_spring.html
  6. An introduction to Spring BlazeDS integration, Christophe Coenraets, http://www.adobe.com/devnet/flex/articles/spring_blazeds_integration.html
  7. Spring Flex Home, http://www.springsource.org/spring-flex
  8. Adobe Open Source BlazeDS, http://opensource.adobe.com/wiki/display/blazeds/BlazeDS
  9. Using The Flash Builder Data Wizard, http://tv.adobe.com/watch/flex-in-a-week-day-3/using-the-flash-builder-data-wizard
  10. BlazeDS Trunk Downloads, http://opensource.adobe.com/wiki/display/blazeds/download+blazeds+trunk
  11. Flex-mojos Maven Plugin, http://flexmojos.sonatype.org/
  12. Installing Galileo Update Site To Flash Builder 4, http://www.flexonjava.net/2010/04/error-when-installing-m2eclipse-on.html 
  13. Adobe Developer Connection, Education, Free Edition Of Flash Builder 4, http://www.adobe.com/devnet/edu.html
  14. Using Spring BlazeDS Integration Nightly Builds With Maven, http://forum.springsource.org/showthread.php?t=77454
  15. Flex Simple Server Example - Archived Java Maven Project
  16. Flex Simple Client Example - Archived Flex Project

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Wow! I can't believe I stumbled across this post. This has just solved days of frustration. You put together all the webcasts + blog posts + forum threads that I'd already read and summarised them step by step in a simple post. Thanks for your hard work on this. Finally I'm in data service heaven. :)
# Posted By Georgi | 1/20/11 11:59 PM
Hi Bruce.
Many thanks for taking time to write this fantastic article.
But there are problems, when I fire my tomcat, it complains about the messagebroker.
Here is the error:

2011-05-16 17:23:20,359 ERROR org.springframework.web.servlet.DispatcherServlet.
initServletBean:314 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nes
ted exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name '_messageBroker': Invocation of init method failed; nest
ed exception is java.lang.NoSuchMethodError: flex.messaging.MessageBroker.releas
eThreadLocalObjects()V
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:291)........
Can you help me ?
Bests regards,
Kwame
PS: googling around, some think that it lack xalan.jar ; but it don't work even when I include it; maybe I did it on a wrong manner????
# Posted By Kwame nkrumah | 5/16/11 10:39 AM
Kwame:

Did you get the BlazeDS Version 4 artifacts added to your local Maven repository (see section above heading Get The BlazeDS Version 4 Artifacts)?

If so, in the root folder for the server application can you do mvn package successfully?
# Posted By Bruce | 5/16/11 11:57 AM
Yes I did.
Also mvn package has been successfully executed. Also the server's war (flexServer in my case)
has been successfully created in my target directory; and I have copied it to tomcat's webapps
Note that I have also created under my WEB-INF an index.html and despite that Error when I fire my browser
as http://localhost:8080/flexServer, I can see the page index.html.
Do you think that error is not so important and that I should continue with the second part of the tutorial (Flex Client application)?
Not sure...

Here is the complete error outputed: (I'm using maven 3 )

16-mag-2011 17.23.11 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performanc
e in production environments was not found on the java.library.path: C:\Programm
i\Java\jdk1.6.0_18\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Programmi\ATI Technol
ogies\ATI.ACE\Core-Static;C:\Programmi\Java\jdk1.6.0_18\bin;C:\maven\apache-mave
n-3.0.3\bin;C:\tomcat\apache-tomcat-6.0.32\bin;C:\Programmi\TortoiseSVN\bin
16-mag-2011 17.23.13 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
16-mag-2011 17.23.13 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2951 ms
16-mag-2011 17.23.13 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
16-mag-2011 17.23.13 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
16-mag-2011 17.23.13 org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
16-mag-2011 17.23.14 org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
16-mag-2011 17.23.14 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive flexServer.war
2011-05-16 17:23:19,984 ERROR org.springframework.flex.core.MessageBrokerFactory
Bean.afterPropertiesSet:198 - Error thrown during MessageBroker initialization
java.lang.NoSuchMethodError: flex.messaging.MessageBroker.createThreadLocalObjec
ts()V
at org.springframework.flex.core.MessageBrokerFactoryBean.initThreadLoca
ls(MessageBrokerFactoryBean.java:354)
at org.springframework.flex.core.MessageBrokerFactoryBean.afterPropertie
sSet(MessageBrokerFactoryBean.java:125)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.AbstractBeanFactory.isSingl
eton(AbstractBeanFactory.java:396)
at org.springframework.context.support.AbstractApplicationContext.isSing
leton(AbstractApplicationContext.java:1095)
at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.reg
isterHandler(AbstractUrlHandlerMapping.java:382)
at org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.regis
terHandlers(SimpleUrlHandlerMapping.java:129)
at org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initA
pplicationContext(SimpleUrlHandlerMapping.java:104)
at org.springframework.context.support.ApplicationObjectSupport.initAppl
icationContext(ApplicationObjectSupport.java:119)
at org.springframework.web.context.support.WebApplicationObjectSupport.i
nitApplicationContext(WebApplicationObjectSupport.java:72)
at org.springframework.context.support.ApplicationObjectSupport.setAppli
cationContext(ApplicationObjectSupport.java:73)
at org.springframework.context.support.ApplicationContextAwareProcessor.
invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106)
at org.springframework.context.support.ApplicationContextAwareProcessor.
postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:85)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanF
actory.java:394)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:425)
at org.springframework.web.servlet.FrameworkServlet.createWebApplication
Context(FrameworkServlet.java:442)
at org.springframework.web.servlet.FrameworkServlet.createWebApplication
Context(FrameworkServlet.java:458)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationCo
ntext(FrameworkServlet.java:339)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(Fram
eworkServlet.java:306)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.
java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:99
3)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:4420)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
733)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
9)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)

at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)

at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778
)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504
)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463
)
at org.apache.catalina.core.StandardService.start(StandardService.java:5
25)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754
)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2011-05-16 17:23:20,359 ERROR org.springframework.web.servlet.DispatcherServlet.
initServletBean:314 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nes
ted exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name '_messageBroker': Invocation of init method failed; nest
ed exception is java.lang.NoSuchMethodError: flex.messaging.MessageBroker.releas
eThreadLocalObjects()V
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:425)
at org.springframework.web.servlet.FrameworkServlet.createWebApplication
Context(FrameworkServlet.java:442)
at org.springframework.web.servlet.FrameworkServlet.createWebApplication
Context(FrameworkServlet.java:458)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationCo
ntext(FrameworkServlet.java:339)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(Fram
eworkServlet.java:306)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.
java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:99
3)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:4420)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
733)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
9)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)

at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)

at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778
)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504
)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463
)
at org.apache.catalina.core.StandardService.start(StandardService.java:5
25)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754
)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name '_messageBroker': Invocation of init method failed; nested exc
eption is java.lang.NoSuchMethodError: flex.messaging.MessageBroker.releaseThrea
dLocalObjects()V
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.AbstractBeanFactory.isSingl
eton(AbstractBeanFactory.java:396)
at org.springframework.context.support.AbstractApplicationContext.isSing
leton(AbstractApplicationContext.java:1095)
at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.reg
isterHandler(AbstractUrlHandlerMapping.java:382)
at org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.regis
terHandlers(SimpleUrlHandlerMapping.java:129)
at org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initA
pplicationContext(SimpleUrlHandlerMapping.java:104)
at org.springframework.context.support.ApplicationObjectSupport.initAppl
icationContext(ApplicationObjectSupport.java:119)
at org.springframework.web.context.support.WebApplicationObjectSupport.i
nitApplicationContext(WebApplicationObjectSupport.java:72)
at org.springframework.context.support.ApplicationObjectSupport.setAppli
cationContext(ApplicationObjectSupport.java:73)
at org.springframework.context.support.ApplicationContextAwareProcessor.
invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106)
at org.springframework.context.support.ApplicationContextAwareProcessor.
postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:85)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanF
actory.java:394)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 40 more
Caused by: java.lang.NoSuchMethodError: flex.messaging.MessageBroker.releaseThre
adLocalObjects()V
at org.springframework.flex.core.MessageBrokerFactoryBean.destroyThreadL
ocals(MessageBrokerFactoryBean.java:365)
at org.springframework.flex.core.MessageBrokerFactoryBean.destroy(Messag
eBrokerFactoryBean.java:219)
at org.springframework.flex.core.MessageBrokerFactoryBean.afterPropertie
sSet(MessageBrokerFactoryBean.java:200)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 59 more
16-mag-2011 17.23.20 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
16-mag-2011 17.23.20 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
16-mag-2011 17.23.21 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
16-mag-2011 17.23.21 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
16-mag-2011 17.23.21 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
16-mag-2011 17.23.21 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/78 config=null
16-mag-2011 17.23.21 org.apache.catalina.startup.Catalina start
INFO: Server startup in 8261 ms
# Posted By Kwame | 5/16/11 12:56 PM
Hi Bruce,

Many Thanks for writing about this article.It helped me a lot in learning BlazeDS with Flex and Java.
Can you please tell me how to use AMF3 in BlazeDS version 4 with Java and Flex.
# Posted By Satish | 9/14/11 5:25 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact Blog Owner