Using Flex with Spring

Many people in the Java community have recently been asking how to use Flex with the Spring framework, and more specifically, how to remotely invoke Spring beans methods from Flex applications.

Spring is one of the most popular Java frameworks. It is based on a lightweight component container that implements the Inversion of Control (IoC) pattern. Using an IoC container, components don’t instantiate or even look up their dependencies (the objects they work with). The container is responsible for injecting those dependencies when it creates the components (hence the term “Dependency Injection” also used to describe this pattern). The result is looser coupling between components. The Spring IoC container has proven to be a solid foundation for building robust enterprise applications.

The Flex and Spring integration process is actually very straightforward. Based on the interest in combining these technologies, I wrote a document providing background information, configuration information, and three examples with source code.

You can read the “Using Flex with Spring” document here.

UPDATE (1/12/2007): I put together a Tomcat-based Test Drive Server that includes these samples running out-of-the box. Read this post for more info.

33 Responses to Using Flex with Spring

  1. kazi October 22, 2006 at 5:10 pm #

    Hello Christophe. Please help…….. I have a ViewStack in my main application ID MyViewStack. The second Child of MyViewStack is a canvas
    which also has a ViewStack ID ChildViewStack. now my question is how do I address the second child of ChildViewStack?

    I tried this but did not work

    mx.core.Application.application.MyViewStack=1.ChildViewStack=1;

    Any help will be highly appreciated.

  2. Fuad Kamal November 14, 2006 at 2:56 pm #

    Christophe, thanks for the article, I’ve been searching for anything explaining how to integrate Java w/Flex and thus far nothing else has come close to the usefulness of your article. I’m porting a Flex 1.5 app to Flex 2, the back-end uses Spring, Hibernate, and Tomcat. It has been a massive pain, perhaps because I never worked in 1.5 prior to this nor do I consider myself a Java developer, and the Adobe docs seem to lack depth in many aspects…

    My question is, can you shed more light (or point to a good reference) on the tags you modified the web.xml file with, specifically the tag? The web.xml tag in our app defined ContextLoaderServlet using a servlet tag while in your article you used a listener tag:

    context
    org.springframework.web.context.ContextLoaderServlet

    1

    vs.

    org.springframework.web.context.ContextLoaderListener

    What’s the difference? The two seem to be mutually exclusive, as having both throws an error that it’s defined twice.

    In my remoting-config.xml I define three destinations corresponding to three Java classes the application uses with remoting. Prior to reading your article I had defined them like this:

    ces-web.dispatch.com.ecarey.ces.service.trip.TripServiceDelegate
    request

    after reading your article I thought perhaps they should look more like this:

    spring TripServiceDelegate
    request

    Given, ofcourse, that I registered the factory as per your article. Any thoughts? Either way I can’t get the app to run under FDS2 yet; it throws a fatal exception from FlexSwfServlet saying ‘invalid configuration’…

    Thanks.

  3. Fuad Kamal November 14, 2006 at 3:04 pm #

    sorry, looks like all the tags got screwed up in my posting (interpreted, I guess). here is the source re-pasted minus the brackets, hope its not too confusing (I suppose I could try it within a CDATA tag but I don’t want to keep posting the same comment to your blog):

    Christophe, thanks for the article, I’ve been searching for anything explaining how to integrate Java w/Flex and thus far nothing else has come close to the usefulness of your article. I’m porting a Flex 1.5 app to Flex 2, the back-end uses Spring, Hibernate, and Tomcat. It has been a massive pain, perhaps because I never worked in 1.5 prior to this nor do I consider myself a Java developer, and the Adobe docs seem to lack depth in many aspects…

    My question is, can you shed more light (or point to a good reference) on the tags you modified the web.xml file with, specifically the tag? The web.xml tag in our app defined ContextLoaderServlet using a servlet tag while in your article you used a listener tag:

    servlet
    servlet-name context servlet-name
    servlet-class org.springframework.web.context.ContextLoaderServlet
    servlet-class
    load-on-startup 1 load-on-startup
    servlet

    vs.

    listener

    listener-class
    org.springframework.web.context.ContextLoaderListener
    listener-class
    listener

    What’s the difference? The two seem to be mutually exclusive, as having both throws an error that it’s defined twice.

    In my remoting-config.xml I define three destinations corresponding to three Java classes the application uses with remoting. Prior to reading your article I had defined them like this:

    destination id=”tripServiceDelegate” adapter=”java-object”>
    properties>
    source>ces-web.dispatch.com.ecarey.ces.service.trip.TripServiceDelegate
    /source>
    scope>
    request
    /scope>
    properties>
    destination>

    after reading your article I thought perhaps they should look more like this:

    destination id=”tripServiceDelegate”>
    properties>
    factory>spring source>TripServiceDelegate
    /source>
    scope>request
    /scope>
    /properties
    /destination

    Given, ofcourse, that I registered the factory as per your article. Any thoughts? Either way I can’t get the app to run under FDS2 yet; it throws a fatal exception from FlexSwfServlet saying ‘invalid configuration’…

    Thanks.

  4. Fuad Kamal November 15, 2006 at 9:49 am #

    When using Flex with Spring as described in your article, can Flex handle run-time exceptions thrown by the Spring beans?

  5. may November 20, 2006 at 10:45 am #

    I am throwing an exception from my spring service and trying to handle it in the fault handler in flex. But for some reason the exception is not propogating to flex. Any suggestions?

  6. Grayson Pierce January 9, 2007 at 10:28 pm #

    Christophe,

    Now let’s see an example of using Flex with acegi

    :)

    GP

  7. Matt Madhavan August 7, 2007 at 8:44 am #

    Hi Cristophe,
    Looks like people are pretty much begging you for Acegi security integration. Any ideas. It will be great if you give some tips on this.

    Thanks
    Matt

  8. Ek5 May 3, 2008 at 8:53 pm #

    I am throwing an exception from my spring service and trying to handle it in the fault handler in flex. But for some reason the exception is not propogating to flex. Any suggestions?
    thank you

  9. sohbet August 22, 2008 at 5:45 pm #

    ThankS.

  10. chat August 22, 2008 at 5:46 pm #

    thankS a lot

  11. çet August 22, 2008 at 5:47 pm #

    thanks good… ;)

  12. çet August 22, 2008 at 6:00 pm #

    thanks good … ;)

  13. chat August 28, 2008 at 10:41 pm #

    thanks you very good

  14. mirc August 28, 2008 at 10:42 pm #

    Looks like people are pretty much begging you for Acegi security integration. Any ideas. It will be great if you give some tips on this.

  15. webmaster August 28, 2008 at 10:43 pm #

    very great thanks you

  16. lapto battery November 20, 2008 at 9:15 pm #

    thanks good … ;)

  17. Sanjay February 19, 2009 at 2:51 am #

    Pls. provide previous contents for “Using Flex with Spring” link (http://coenraets.org/flex-spring)

  18. toki konutları February 23, 2009 at 4:14 pm #

    Looks like people are pretty much begging you for Acegi security integration. Any ideas

  19. araç sorgulama March 17, 2009 at 4:53 pm #

    very great thanks you

  20. sxe indir June 13, 2010 at 9:17 am #

    Thanks your post admin.

  21. matbaa August 8, 2010 at 7:52 am #

    very great thanks you

  22. chiller servisi October 4, 2014 at 12:44 pm #

    very very good süper bişeyler

    http://www.sogutmaservisiistanbul.com

  23. merkezi sogutma October 16, 2014 at 2:04 pm #

    çalışmaya devam arkadaşlar

  24. General Electric Servisi January 31, 2015 at 4:26 pm #

    I am throwing an exception from my spring service and trying to handle it in the fault handler in flex. But for some reason the exception is not propogating to flex. Any suggestions?

  25. Health Tourism January 31, 2015 at 9:05 pm #

    very great thanks you

  26. Sohbet October 30, 2015 at 7:04 pm #

    thnx

  27. chat October 30, 2015 at 7:05 pm #

    thnxk

  28. Yemek October 30, 2015 at 7:05 pm #

    feed food

  29. antrenman malzemeleri November 24, 2015 at 7:05 am #

    kalite,seri üretim ve uygun fiyatlar firmamızda

  30. yuvaraj singh December 10, 2020 at 5:56 am #

    Thanks for sharing this informative content ,
    Leanpitch provides online training in Devops during this lockdown period everyone can use it wisely.
    Devops Online Training

Trackbacks/Pingbacks

  1. Ezmo Developer Blog » Using Flex Data Services with Spring and Hibernate - July 18, 2007

    […] 3. I then learned about integrating FDS with Spring, exemplified in Christophe Coenraets blog. The next step was to combine what I had learned from the Hibernate- and the Spring examples. […]

  2. It’s all about RIA - October 14, 2008

    […] Using Flex with Spring […]

  3. It’s all about RIA - October 14, 2008

    […] Comment! Using Flex with Spring […]

Leave a Reply

css.php