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.

  • kazi

    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.

  • 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.

  • 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.

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

  • may

    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?

  • Grayson Pierce

    Christophe,

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

    :)

    GP

  • Pingback: Ezmo Developer Blog » Using Flex Data Services with Spring and Hibernate()

  • Matt Madhavan

    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

  • Ek5

    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

  • ThankS.

  • thankS a lot

  • thanks good… ;)

  • thanks good … ;)

  • thanks you very good

  • 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.

  • very great thanks you

  • Pingback: It’s all about RIA()

  • Pingback: It’s all about RIA()

  • thanks good … ;)

  • Sanjay

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

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

  • very great thanks you

  • Thanks your post admin.

  • very great thanks you

  • very very good süper bişeyler

    http://www.sogutmaservisiistanbul.com

  • çalışmaya devam arkadaşlar

  • 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?

  • very great thanks you

  • thnx

  • thnxk

  • feed food

  • kalite,seri üretim ve uygun fiyatlar firmamızda

css.php