Announcement Announcement Module
Collapse
No announcement yet.
Spring Integration + webapps: accesing beans in the main context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Integration + webapps: accesing beans in the main context

    Hi all,
    I have Spring Integration working within a webapp (using Tomcat). Following another post in this forum, I got it starting a different context for the integration part, from a bean initialized in the main webapp.
    It works fine now, but... I cannot access the beans of the webapp context. I'd like to use some of the business layer services. They are using spring transactions (@Transactional on their interfaces), so instantiate them "by hand" doesn't seem to be a good option.
    Any idea?

    Thanks in advance

  • #2
    Can you explain the separation of your application contexts in a bit more detail?

    The simplest solution is probably to include the Spring Integration configuration files within the "contextConfigLocation" parameter so that your ContextLoaderListener will create the integration components within the same context as your service layer.

    Comment


    • #3
      The thing is that I wasn't able to get spring integration working within the context of a web application. I guess it's related with some limitation of the WebApplicationContext...
      So, following the instruction of this thread, I'm initializating a new context from a bean of the web application, containing all the spring integration stuff. That's why I have two different contexts.
      After some try and fix, now I'm accesing the beans of the main context by accessing directly the web application context with
      WebApplicationContext webContext = ContextLoader.getCurrentWebApplicationContext();
      webContext.getBean("BeanName");

      It actually works fine, but I still find the solution a little bit "dirty"

      Comment


      • #4
        What version of Spring Integration are you using? The auto-startup for MessageBus was added in M2.

        Comment


        • #5
          I'm using 1.0.0.m2 (downloaded from your maven repository: http://s3.amazonaws.com/maven.spring....org/milestone)

          Comment


          • #6
            The M2 version of MessageBus has autoStartup="true" by default. So, it should be finding all channel and endpoint definitions within its context and then activating those endpoints. Can you provide a code excerpt of what you are having to do manually?

            Comment


            • #7
              Oh damn! I got in a mess with the versions because I haven't realized that "spring-integration-adapters" was a different maven artifact in milestone 2, so in some deseperation moment I went back to m1...
              Now it works fine without all that workarounds.

              Many thanks for your efforts Mark

              Comment


              • #8
                Glad to hear that it's working! Sorry about the confusion with the different JAR. Be sure to consult the README.TXT file within each new release (especially during the milestone phases) in case there are additional modularity changes.

                -Mark

                Comment

                Working...
                X