Announcement Announcement Module
Collapse
No announcement yet.
inter-container dependency problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • inter-container dependency problem

    hi,

    i'm having problems with inter-container dependencies between a parent and child container when the parent is loaded in a ContextLoaderListener (needed for spring security) and the child is loaded in a DispatcherServlet.

    For example: Spring Security OAuth2 context needs to be loaded in the ContextLoaderListener (because it needs to leverage the DelegatingFilterProxyfilter to execute the springSecurityFilterChain).

    However, the problem here is that Spring Security OAuth2 provides a few @Controller classes. The @Controller classes are loaded in the parent container while the @EnableWebMCV Feature is enabled on the DispatcherServlet container. The result is that the Spring Security OAuth2 controllers are not available, which breaks the whole module. Moving the Spring Security OAuth2 configuration into the DispatcherServlet is not an option, because it then the springSecurityFilterChain is not available.

    The same problem occurs also with TransactionManagement (as @Transactional methods are only woven in the container where the Feature is enabled) and is not related to Spring Security OAuth2 in particular.

    A solution might be to load everything twice, but that seems a little silly. Maybe i don't understand the container concept. Any help on this subject would be much appreciated as I do not have any resolution to the problem.

    cheers
    Last edited by vonbrittelstrausse; Jan 23rd, 2012, 12:56 PM.

  • #2
    Why would you need @Transactional in the dispatcherservlet any way? The dispatcher servlet should only contain web related beans and nothing else and your controllers shouldn't be the transactional layer, the service layer should be (and that should be in the contextloaderlistener).

    Regarding the @Controller classes what is wrong with moving them simply to the dispatcherservlet? If that is a problem you can always configure the RequestMappingHandlerAdapter to also look in the parent context for @Controller annotated beans.

    Comment


    • #3
      Thanks for the answer Martin.

      The @Transactional was merely a example to amend the problem, but point taken anyway.

      Changing the RequestMappingHandlerAdapter to load the @Controller's from the parent context sounds good.

      Bedankt

      Comment


      • #4
        Any pointers on how do load the @Controllers from the parent context? Does the default BeanFactory needs changing?

        Cheers

        Comment


        • #5
          DefaultAnnotationHandlerMapping has a detectHandlersInAncestorContexts property that enables the desired behaviour.

          Comment

          Working...
          X