New Update to the Spring BlazeDS Integration Test Drive

I made some additional changes to the Spring BlazeDS Integration (RC1) Test Drive:

  • The Test Drive now includes an annotation-based configuration sample (the Company Manager sample). Spring annotations such as @Service, @RemotingDestination, @Autowired, @RemotingInclude, and @RemotingExclude make it really easy to configure your beans and make them available through Remoting. As an example, here is the source code for the CompanyDAO class:

    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import javax.sql.DataSource;
    import org.springframework.flex.remoting.RemotingDestination;
    import org.springframework.flex.remoting.RemotingExclude;
    import org.springframework.flex.remoting.RemotingInclude;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
    import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
    import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
    import flex.spring.samples.industry.IIndustryDAO;
    public class CompanyDAO implements ICompanyDAO {
    	private final SimpleJdbcTemplate template;
    	private final SimpleJdbcInsert insertCompany;
    	private IIndustryDAO industryDAO;
    	private final ParameterizedRowMapper<Company> rowMapper = new ParameterizedRowMapper<Company>(){
    		public Company mapRow(ResultSet rs, int rowNum) throws SQLException {
    			Company company = new Company();
    			return company;
    	public CompanyDAO(DataSource dataSource, IIndustryDAO industryDAO) {
    		template = new SimpleJdbcTemplate(dataSource);
    		insertCompany = new SimpleJdbcInsert(dataSource).withTableName("COMPANY").usingGeneratedKeyColumns("ID");
    		this.industryDAO = industryDAO;
    	public Company findById(int id) {
    		return template.queryForObject("SELECT * FROM company WHERE id=?", rowMapper, id);
    	public List<Company> findAll() {
    		return template.query("SELECT * FROM company ORDER BY name", rowMapper);
    	public List<Company> findByName(String name) {
    		return template.query("SELECT * FROM company WHERE UPPER(name) LIKE ? ORDER BY name",
    				"%" + name.toUpperCase() + "%");
    	public Company create(Company company) {
    		Map<String, Object> parameters = new HashMap<String, Object>();
            parameters.put("name", company.getName());
            parameters.put("address", company.getAddress());
            parameters.put("city", company.getCity());
            parameters.put("state", company.getState());
            parameters.put("zip", company.getZip());
            parameters.put("phone", company.getPhone());
            parameters.put("industry_id", company.getIndustry().getId());
            Number id = insertCompany.executeAndReturnKey(parameters);
    		return company;
    	public boolean update(Company company) {
            int count = template.update("UPDATE company SET name=?, address=?, city=?, state=?, zip=?, phone=?, industry_id=? WHERE id=?",
    		return (count == 1);
    	public boolean remove(Company company) {
    		int count = template.update("DELETE FROM company WHERE id=?", company.getId());
    		return (count == 1);

  • The Test Drive is now using the M3 build of Spring 3 (as opposed to M2 in the previous builds of the Test Drive).
  • I modified the configuration of the long polling channel to support more persistent connections per domain based on the browser capabilities.
  • And of course compared to the M2 build, this version of the Test Drive includes a number of Messaging samples.

    Using the Messaging integration, setting up a destination can be as easy as:

    <flex:message-destination id="chat" />

    And here is how you configure a destination mapped to a JMS topic:

    <flex:jms-message-destination id="jms-chat" jms-destination="chatTopic" />

Installation Instructions:

  1. Download the Spring / Flex TestDrive here:
  2. Unzip it in your root directory
  3. Navigate to /spring-flex-testdrive/tomcat/bin and start Tomcat (for instance: catalina run)
  4. Open a browser and access http://localhost:8080
  5. Follow the instructions

  • Monger

    Amazing. Thank you, Christophe for making my life easier. You’re doing some amazing work! Keep it up!

  • Rares

    Hi, the examples work fine but it would be wonderful if you include in the archive the project’s build scripts (ant or maven) beside the source files. I am unable to find on the web an official post about how Java and Flex 3 projects should be build using maven/ant. I’m trying for about a week now to create a deployment script and still didn’t find the best way to do it, especially what maven plugins to use… It would be great to have such an example. Thanks in advance !

  • Kannan


    It is a fantastic work. I would like to know some information related to search box, Currently I think the pop-up list position is like list.move(point.x – 30, point.y + 24);

    but if I wanted to reuse this search box in many screens , where the box can be at various position, the pop up appears in different location, instead I always wanted to have it like a drop down. Can you please help on how to fix this.(since I am a java programmer and new to flex, please help, as we are planning to start a new project with spring blazeDS)

  • Yeudy

    Hi Christophe, thank you, great work!

  • claudio

    Hi, very nice,

    The problem for me, and creating an environment to test. I purchased Flex Builder 3 but I do not understand how to set up for Spring-Hibernate-Mysql
    help me.

    Claudio Italy

  • Rahul

    I am trying to upgrade my existing HelloWorld Blazeds Integration web application to 1.0.0.RC1 Release. I just annoted my Service class with @Service(“helloWorldService”) ,@RemotingDestination(channels={“my-amf”})
    and method with @RemotingInclude.
    I removed the bean declaration and flex:remote-service tag from web-application-config.xml. Although flex:message-broker tag still there.
    With these changes in place, I am expecting the application to work, but it just deploys successfully. When tried to invoke method from flex client, nothing happens.
    Am I missing something? Please help.


  • Pingback: 14/05/2009 « Robertopriz’s Weblog()

  • Thanks for sharing this Christophe !

    I’m glad that SpringSource finally released that annotation mechanism, that we had for long in our flex-spring-contrib lib.

    Would you Christophe if they plan on adding springsecurity/blazeds_channel_security integration annotations as well ?

  • Rocky

    Hi Christophe,

    I would appreciate if you can provide some details regarding “using my-secure-amf”.

    Thanks in advance!

  • Excellent Job!

    Particularly on Spring Security and JMS Integrations. Great Updates…

    Thanks for sharing Christophe and Jeremy.

  • Is there official support for Glassfish instead of Tomcat?

  • robin bakkerus

    Hi Christophe,

    Could you also supply a working testdrive that runs on the new Springsource dm server.

    Thank you in advance

  • Oleg


    Excellent work !

    Couple of things:
    1) it would be very beneficial to everybody if there is a good documentation on these samples, e.g. describing steps to configure it in Tomcat and Flex/FlashBuilder;
    2) Spring-to-Flex integration API documentation ?
    3) Can you provide Flex4 version of samples? Any limitations/problems to make it work with Flex4 ?
    4) Can it work with Spring2.x and earlier versions of BlazeDS & LCDS ?

    Thank you,

  • Oleg


    When are you planning to release 1.0 GA testdrive.
    I got latest one from SpringSource and started playing with it.

    I have imported 1.0 GA testdrive source code into FlexBuilder3 and trying to run on Tomcat6 which came up with testdrive M2
    (on Christophe Coenraets’ site).
    I did create another app context (feedstarter1 and traderdesktop1), so it should not interfere with existing M2 ones.
    Have not changed anything in the code or testdrive config.

    It compiles and shows on the page fine, but as soon as I start a Market Feed, getting exception:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at traderdesktop/messageHandler()[C:\Documents and Settings\Oleg\workspace\TraderDesktop\src\traderdesktop.mxml:95]
    at mx.messaging::AbstractConsumer/[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\]
    at mx.messaging::ConsumerMessageDispatcher/messageHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\]
    at mx.messaging::ChannelSet/messageHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\]
    at PollCommandMessageResponder/resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\]
    at mx.messaging::MessageResponder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\]

    line 95 of
    94: var changedStock:Stock = event.message.body as Stock;
    95: var stock:Stock = stockMap[changedStock.symbol];

    What am I missing ?

    Please help !


  • Oleg


    It would be great if you can implement a Flex client from the real JMS like ActiveMQ using JMSadapter, e.g. the same TraderDesktop.

    Similar JMS chat with ActiveMQ & BlazeDS:

    Thank you,

  • I gort some error for using this update

    the Spring BlazeDS Integration Test Drive

    Let me download and try again


  • Alberto

    Hi Christophe,

    On the Flex side, I see you have commented the streaming-amf channel from any ChannelSet. Is there any reason for this? cause I can’t make a message destination based on this channel to work :/

    Longpolling, polling, etc seem to work fine but streaming-amf channel is not working. Im using latest spring-for-blazeds jar, etc.

    Any ideas?

    Thank you in advance.


  • Paul

    Hi, I´m very new to java but I know flex.
    Do you know a tutorial to create a new project from scratch in eclipse. like a best practices for new projects ?

  • enigma

    Thank you very much !! … test drive is very useful.

  • thank you man

  • model ve mankenlik ajansı

  • fotoğraf çekimleri

  • program yükle Good admin than you

  • Christophe,

    Thanks for all your hard work. It has not only taught me a LOT, but has helped me tremendously!

    – Derrick

  • Pingback: Using SpringMVC next to BlazeDS « 3 character abbreviation()

  • xcom

    version tomcat 6.18???? o not

  • Pingback: Jacob Heric » Blog Archive » Spring Flex integration with BlazeDS()

  • Darin Boyd

    I couldn’t get it to run.

  • I’m trying for about a week now to create a deployment script and still didn’t find the best way to do it, especially what maven plugins to use… It would be great to have such an example. Thanks in advance !

  • Great coding! It’s great that you have included the codes and examples for us readers to follow.

  • Victor

    Not Found

    The requested URL /downloads/ was not found on this server.
    Apache/2.2.21 (Amazon) Server at Port 80

    Can someone please upload the file again?

  • yuvaraj singh

    Thanks for sharing this informative content
    Leanpitch provides online training in Enterprise Agile coaching during this lockdown period everyone can use it wisely.
    Enterprise Agile coaching